Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
Rendering multiple image blob ulrs using react result in corrupted images

I'm trying to build an app that takes an image file as input, posts it to the server, and receives a styled image as blob URL. The problem is that some of the received images are sometimes corrupted. There is no pattern here and some of them are randomly corrupted. And sometimes it works fine with no corrupted images. Here are the relevant code snippets. I'm using django-rest framework for the backend.

var styled_images = []

function StyleTransferCarousel() {
    const [styledImages, setStyledImages] = useState([])
    const [styled, setStyled] = useState(false)

    // this function gets the image blob from server
    const getStyledImage = async (model) => {
            var formData = new FormData()
            ...
            try {
                const { data } = await axios.post('/style_transfer/stylev2/', formData, config)
                return data
            } catch (error) {...}
        }
    
    // this function gets the image blob untill the size of image list is equal to available models and re-renders
    async function getStyledImages() {
            var styledImageDict = {}
            for (let i = 0; i < models.length; i++) {
                var model_i = models[i]
                var data = getStyledImage(model_i)
                data.then(data => {
                    styledImageDict = {
                        image: "data:image/png;base64," + data.image,
                        model: models[i]
                    }
                    styled_images = styled_images.concat([styledImageDict])
                    if (styled_images.length !== models.length) {
                        setLoader(false)
                        setStyledImages(styled_images) //react hook
                    }
                })
            }

    }
    
// this is called once, if images are not styled
    useEffect(() => {
        if (models.length !== 0 && !styled) {
            //styled = true
            setStyled(true)
            getStyledImages()
            setLoader(true)
        }
    }, [models])
...
}

The images setStyledImages object are rendered. Some examples of corrupted images are below: enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda