Spaces:
Build error
Build error
fix file upload
#6
by
radames
- opened
app.py
CHANGED
|
@@ -54,7 +54,8 @@ fetch(url)
|
|
| 54 |
get_js_image = """
|
| 55 |
async (image_in_img, prompt, image_file_live_opt, live_conditioning) => {
|
| 56 |
const canvasEl = document.getElementById("canvas-root");
|
| 57 |
-
|
|
|
|
| 58 |
}
|
| 59 |
"""
|
| 60 |
|
|
@@ -145,14 +146,15 @@ def generate_images(image_in_img, prompt, image_file_live_opt='file', live_condi
|
|
| 145 |
if image_in_img is None and 'image' not in live_conditioning:
|
| 146 |
raise gr.Error("Please provide an image")
|
| 147 |
|
| 148 |
-
if image_file_live_opt == 'file':
|
| 149 |
-
conditioning = get_conditioning(image_in_img)
|
| 150 |
-
elif image_file_live_opt == 'webcam':
|
| 151 |
-
base64_img = live_conditioning['image']
|
| 152 |
-
image_data = base64.b64decode(base64_img.split(',')[1])
|
| 153 |
-
conditioning = Image.open(BytesIO(image_data)).convert('RGB').resize((512,512))
|
| 154 |
-
|
| 155 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
output = pipe(
|
| 157 |
prompt,
|
| 158 |
conditioning,
|
|
@@ -164,7 +166,6 @@ def generate_images(image_in_img, prompt, image_file_live_opt='file', live_condi
|
|
| 164 |
except Exception as e:
|
| 165 |
raise gr.Error(str(e))
|
| 166 |
|
| 167 |
-
|
| 168 |
def toggle(choice):
|
| 169 |
if choice == "file":
|
| 170 |
return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
|
|
|
|
| 54 |
get_js_image = """
|
| 55 |
async (image_in_img, prompt, image_file_live_opt, live_conditioning) => {
|
| 56 |
const canvasEl = document.getElementById("canvas-root");
|
| 57 |
+
const imageData = canvasEl? canvasEl._data : null;
|
| 58 |
+
return [image_in_img, prompt, image_file_live_opt, imageData]
|
| 59 |
}
|
| 60 |
"""
|
| 61 |
|
|
|
|
| 146 |
if image_in_img is None and 'image' not in live_conditioning:
|
| 147 |
raise gr.Error("Please provide an image")
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
try:
|
| 150 |
+
if image_file_live_opt == 'file':
|
| 151 |
+
conditioning = get_conditioning(image_in_img)
|
| 152 |
+
elif image_file_live_opt == 'webcam':
|
| 153 |
+
base64_img = live_conditioning['image']
|
| 154 |
+
image_data = base64.b64decode(base64_img.split(',')[1])
|
| 155 |
+
conditioning = Image.open(BytesIO(image_data)).convert(
|
| 156 |
+
'RGB').resize((512, 512))
|
| 157 |
+
|
| 158 |
output = pipe(
|
| 159 |
prompt,
|
| 160 |
conditioning,
|
|
|
|
| 166 |
except Exception as e:
|
| 167 |
raise gr.Error(str(e))
|
| 168 |
|
|
|
|
| 169 |
def toggle(choice):
|
| 170 |
if choice == "file":
|
| 171 |
return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
|