#Strange Output using openai.Create.Image()

7 messages · Page 1 of 1 (latest)

hollow ridge
#

Hello,

I'm using Flask webapp with DALL-E API, and I am trying to generate image based on prompt from form, there is no errors in logs or consoles, but somehow it always return me this strange text image no matter what prompt I wrote. Here is my code below:

app.py

app.py

@app.route('/generate', methods=['POST'])
def generate():
    # Get the text to generate an image for
    text = request.form.get('text')
    # Set the prompt for the image
    prompt = f"Write a description of the image you want to generate based on the following text: {text}"
    model = "image-alpha-001"
    num_images = 1
    size = "1024x1024"
    response_format = "url"
    # Generate the image
    response = openai.Image.create( 
        model=model,
        prompt=prompt,
        n=num_images,
        size=size,
        response_format=response_format 
    ) 
    
    # Return the generated image URL to the client 
    return jsonify({'url': response['data'][0]['url']})
hollow ridge
eager field
#

though kinda weird it would generate something that odd

#

ALso just looking at issues online, wrt request.form, I see this used: @app.route(/<path>', methods = ['GET', 'POST']), maybe if you added 'GET' to your method?

hollow ridge