Freiburg-AI-Research commited on
Commit
bce7d81
Β·
1 Parent(s): 4ae0168

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -133,7 +133,12 @@ def model_fn(x_t, ts, **kwargs):
133
  eps = th.cat([half_eps, half_eps], dim=0)
134
  return th.cat([eps, rest], dim=1)
135
 
136
-
 
 
 
 
 
137
  # @app.get("/")
138
  def read_root():
139
  return {"glide!"}
@@ -232,15 +237,11 @@ def sample(prompt):
232
  # Show the output
233
  image = get_images(up_samples)
234
  image = to_base64(image)
235
- return {"image": image}
236
  return image
237
 
238
 
239
- def to_base64(pil_image, size=(64, 64)):
240
- pil_image.thumbnail(size, Image.ANTIALIAS)
241
- buffered = BytesIO()
242
- pil_image.save(buffered, format="JPEG")
243
- return base64.b64encode(buffered.getvalue())
244
 
245
  title = "Interactive demo: glide-text2im dermoscopic image generator"
246
  description = "Demo for the Finetuned version of OpenAI's GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models. Please be aware that generation of the image will take up to 20 minutes, as CPU is used for the generation. Please cite our research paper with the title -Finetuning of GLIDE stable diffusion model for AI-based text-conditional image synthesis of dermoscopic images-"
 
133
  eps = th.cat([half_eps, half_eps], dim=0)
134
  return th.cat([eps, rest], dim=1)
135
 
136
+ def to_base64(pil_image, size=(64, 64)):
137
+ pil_image.thumbnail(size, Image.ANTIALIAS)
138
+ buffered = BytesIO()
139
+ pil_image.save(buffered, format="JPEG")
140
+ return base64.b64encode(buffered.getvalue())
141
+
142
  # @app.get("/")
143
  def read_root():
144
  return {"glide!"}
 
237
  # Show the output
238
  image = get_images(up_samples)
239
  image = to_base64(image)
240
+ #return {"image": image}
241
  return image
242
 
243
 
244
+
 
 
 
 
245
 
246
  title = "Interactive demo: glide-text2im dermoscopic image generator"
247
  description = "Demo for the Finetuned version of OpenAI's GLIDE: Towards Photorealistic Image Generation and Editing with Text-Guided Diffusion Models. Please be aware that generation of the image will take up to 20 minutes, as CPU is used for the generation. Please cite our research paper with the title -Finetuning of GLIDE stable diffusion model for AI-based text-conditional image synthesis of dermoscopic images-"