KingNish commited on
Commit
0e6e27c
1 Parent(s): ae17946

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -9,7 +9,6 @@ import urllib.parse
9
  import asyncio
10
  import aiohttp
11
  import threading
12
- import PIL
13
 
14
  app = FastAPI()
15
 
@@ -421,6 +420,8 @@ async def ask_website(url: str, question: str, model: str = "llama-3-70b", proxy
421
  from huggingface_hub import InferenceClient
422
  client_sd3 = InferenceClient("stabilityai/stable-diffusion-3-medium-diffusers")
423
 
 
 
424
  @app.get("/api/sd3")
425
  def sd3(prompt :str = "",
426
  steps: int = "20",
@@ -431,9 +432,10 @@ def sd3(prompt :str = "",
431
  image = client_sd3.text_to_image(prompt = f"{prompt}, hd, high quality, 4k, masterpiece",
432
  num_inference_steps = steps,
433
  width = width, height = height )
434
- return image.save(f"{prompt}.jpg")
 
435
  except Exception as e:
436
- raise HTTPException(detail=f"Error during image generation: {e}")
437
 
438
  @app.get("/api/maps")
439
  async def maps(
 
9
  import asyncio
10
  import aiohttp
11
  import threading
 
12
 
13
  app = FastAPI()
14
 
 
420
  from huggingface_hub import InferenceClient
421
  client_sd3 = InferenceClient("stabilityai/stable-diffusion-3-medium-diffusers")
422
 
423
+ from PIL import Image
424
+
425
  @app.get("/api/sd3")
426
  def sd3(prompt :str = "",
427
  steps: int = "20",
 
432
  image = client_sd3.text_to_image(prompt = f"{prompt}, hd, high quality, 4k, masterpiece",
433
  num_inference_steps = steps,
434
  width = width, height = height )
435
+ image = Image.open(io.BytesIO(image))
436
+ return image
437
  except Exception as e:
438
+ raise HTTPException(status_code=500, detail=f"Error during image generation: {e}")
439
 
440
  @app.get("/api/maps")
441
  async def maps(