Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
#Save ZeroGPU limited resources, switch to InferenceAPI
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
import numpy as np
|
@@ -9,6 +8,7 @@ import requests
|
|
9 |
import re
|
10 |
import asyncio
|
11 |
from PIL import Image
|
|
|
12 |
|
13 |
translator = Translator()
|
14 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
@@ -62,10 +62,16 @@ async def generate_image(
|
|
62 |
num_inference_steps=steps,
|
63 |
model=model,
|
64 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
except Exception as e:
|
66 |
raise gr.Error(f"Error in {e}")
|
67 |
-
|
68 |
-
return image, seed
|
69 |
|
70 |
async def gen(
|
71 |
prompt:str,
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
|
|
8 |
import re
|
9 |
import asyncio
|
10 |
from PIL import Image
|
11 |
+
import io
|
12 |
|
13 |
translator = Translator()
|
14 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
|
62 |
num_inference_steps=steps,
|
63 |
model=model,
|
64 |
)
|
65 |
+
|
66 |
+
# Convert WebP to PNG
|
67 |
+
img = Image.open(io.BytesIO(image))
|
68 |
+
png_image = io.BytesIO()
|
69 |
+
img.save(png_image, format="PNG")
|
70 |
+
png_image.seek(0)
|
71 |
+
|
72 |
+
return png_image, seed
|
73 |
except Exception as e:
|
74 |
raise gr.Error(f"Error in {e}")
|
|
|
|
|
75 |
|
76 |
async def gen(
|
77 |
prompt:str,
|