AryanVerma64 commited on
Commit
79d16a5
·
verified ·
1 Parent(s): ffdf35f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -25,7 +25,10 @@ def predict(ImageUrl,imgDraw,imgUplod):
25
  #fetch the image from url or handwritten canvas or the uplaoded image
26
  if ImageUrl :
27
  image = Image.open(requests.get(ImageUrl, stream=True).raw).convert("RGB")
28
- elif imgDraw :
 
 
 
29
  image = imgDraw.convert("RGB")
30
  else :
31
  image = imgUplod.convert("RGB")
@@ -39,7 +42,7 @@ def predict(ImageUrl,imgDraw,imgUplod):
39
  #gradio interface
40
  interface = gr.Interface(
41
  fn=predict,
42
- inputs=["text", gr.Image(type="pil", source="canvas"), gr.Image(type="pil")],
43
  outputs="text",
44
  title=title,
45
  description=description,
 
25
  #fetch the image from url or handwritten canvas or the uplaoded image
26
  if ImageUrl :
27
  image = Image.open(requests.get(ImageUrl, stream=True).raw).convert("RGB")
28
+ elif imgDraw :
29
+ # Handle Gradio 4+ sketchpad returning a dictionary
30
+ if isinstance(imgDraw, dict) and "composite" in imgDraw:
31
+ imgDraw = imgDraw["composite"]
32
  image = imgDraw.convert("RGB")
33
  else :
34
  image = imgUplod.convert("RGB")
 
42
  #gradio interface
43
  interface = gr.Interface(
44
  fn=predict,
45
+ inputs=["text", gr.Sketchpad(type="pil"), gr.Image(type="pil")],
46
  outputs="text",
47
  title=title,
48
  description=description,