Jamiiwej2903 commited on
Commit
e593310
1 Parent(s): ac1eaa7

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -5
main.py CHANGED
@@ -18,8 +18,7 @@ class Item(BaseModel):
18
  height: int = 512
19
 
20
  def generate_image(item: Item):
21
- image = client.image_to_image(
22
- image=None, # We're using text-to-image, so this is None
23
  prompt=item.prompt,
24
  negative_prompt=item.negative_prompt,
25
  num_inference_steps=item.num_inference_steps,
@@ -32,14 +31,14 @@ def generate_image(item: Item):
32
  @app.post("/generate_image/")
33
  async def generate_image_api(item: Item):
34
  image = generate_image(item)
35
-
36
  # Convert the image to a byte stream
37
  img_byte_arr = io.BytesIO()
38
  image.save(img_byte_arr, format='PNG')
39
  img_byte_arr.seek(0)
40
-
41
  # Return the image as a streaming response
42
  return StreamingResponse(img_byte_arr, media_type="image/png")
43
 
44
  if __name__ == "__main__":
45
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
18
  height: int = 512
19
 
20
  def generate_image(item: Item):
21
+ image = client.text_to_image(
 
22
  prompt=item.prompt,
23
  negative_prompt=item.negative_prompt,
24
  num_inference_steps=item.num_inference_steps,
 
31
  @app.post("/generate_image/")
32
  async def generate_image_api(item: Item):
33
  image = generate_image(item)
34
+
35
  # Convert the image to a byte stream
36
  img_byte_arr = io.BytesIO()
37
  image.save(img_byte_arr, format='PNG')
38
  img_byte_arr.seek(0)
39
+
40
  # Return the image as a streaming response
41
  return StreamingResponse(img_byte_arr, media_type="image/png")
42
 
43
  if __name__ == "__main__":
44
+ uvicorn.run(app, host="0.0.0.0", port=7860)