Spaces:
Running
Running
Update app.py
Browse filesLittle bug fixes in image gen
app.py
CHANGED
@@ -297,19 +297,21 @@ def make_image(prompt, user, pwd):
|
|
297 |
msg = 'Error: unable to create image.'
|
298 |
fpath = None
|
299 |
if user in unames and pwd == pwdList[unames.index(user)]:
|
300 |
-
|
301 |
-
|
302 |
try:
|
|
|
|
|
303 |
image_data = response.data[0].b64_json
|
304 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
305 |
fpath = dataDir + user + '.png'
|
306 |
image.save(fpath)
|
307 |
msg = 'Image created!'
|
308 |
except:
|
309 |
-
return [
|
310 |
else:
|
311 |
msg = 'Incorrect user name or password'
|
312 |
-
return [
|
313 |
return [fpath, msg]
|
314 |
|
315 |
|
|
|
297 |
msg = 'Error: unable to create image.'
|
298 |
fpath = None
|
299 |
if user in unames and pwd == pwdList[unames.index(user)]:
|
300 |
+
if len(prompt.strip()) == 0:
|
301 |
+
return [None, 'You must provide a prompt']
|
302 |
try:
|
303 |
+
response = client.images.generate(model='dall-e-2', prompt=prompt,size='512x512',
|
304 |
+
quality='standard', response_format='b64_json')
|
305 |
image_data = response.data[0].b64_json
|
306 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
307 |
fpath = dataDir + user + '.png'
|
308 |
image.save(fpath)
|
309 |
msg = 'Image created!'
|
310 |
except:
|
311 |
+
return [None, msg]
|
312 |
else:
|
313 |
msg = 'Incorrect user name or password'
|
314 |
+
return [None, msg]
|
315 |
return [fpath, msg]
|
316 |
|
317 |
|