TieuDaoChanNhan commited on
Commit
15223ef
·
1 Parent(s): 74a2c74
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -272,6 +272,16 @@ def gradio_wrapper(input_image):
272
  img = img[0]
273
  return img
274
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  if __name__ == "__main__":
277
  # try:
@@ -279,13 +289,20 @@ if __name__ == "__main__":
279
  # print("gradio:", gr.__version__, "gradio-client:", _gc.__version__)
280
  # except Exception:
281
  # print("gradio:", gr.__version__)
282
-
283
  demo = gr.Interface(
284
- fn=generate_emoji_fixed,
285
  inputs=gr.Image(type="pil", label="Upload Image"),
286
  outputs=gr.Image(type="pil", label="Generated Emoji"),
287
  title="DTN Face-to-Emoji Generator"
288
  )
 
 
 
 
 
 
 
289
 
290
 
291
  print("✅ Gradio interface created!")
 
272
  img = img[0]
273
  return img
274
 
275
+ def safe_gradio_wrapper(input_image):
276
+ """Safe wrapper to handle gradio schema errors"""
277
+ try:
278
+ if input_image is None:
279
+ return Image.new('RGB', (256, 256), color='lightgray')
280
+ result = generate_emoji_fixed(input_image)
281
+ return result
282
+ except Exception as e:
283
+ print(f"Error in gradio wrapper: {e}")
284
+ return Image.new('RGB', (256, 256), color='red')
285
 
286
  if __name__ == "__main__":
287
  # try:
 
289
  # print("gradio:", gr.__version__, "gradio-client:", _gc.__version__)
290
  # except Exception:
291
  # print("gradio:", gr.__version__)
292
+
293
  demo = gr.Interface(
294
+ fn=safe_gradio_wrapper,
295
  inputs=gr.Image(type="pil", label="Upload Image"),
296
  outputs=gr.Image(type="pil", label="Generated Emoji"),
297
  title="DTN Face-to-Emoji Generator"
298
  )
299
+
300
+ # demo = gr.Interface(
301
+ # fn=generate_emoji_fixed,
302
+ # inputs=gr.Image(type="pil", label="Upload Image"),
303
+ # outputs=gr.Image(type="pil", label="Generated Emoji"),
304
+ # title="DTN Face-to-Emoji Generator"
305
+ # )
306
 
307
 
308
  print("✅ Gradio interface created!")