baudm commited on
Commit
ed9d291
β€’
1 Parent(s): ac810fa

Upgrade to Gradio 4.36

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +4 -2
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ“š
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.1.3
8
  python_version: 3.9.13
9
  app_file: app.py
10
  pinned: false
 
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 4.36.1
8
  python_version: 3.9.13
9
  app_file: app.py
10
  pinned: false
app.py CHANGED
@@ -45,6 +45,8 @@ class App:
45
  def __call__(self, model_name, image):
46
  if image is None:
47
  return '', []
 
 
48
  model = self._get_model(model_name)
49
  image = self._preprocess(image.convert('RGB')).unsqueeze(0)
50
  # Greedy decoding
@@ -79,11 +81,11 @@ def main():
79
  model_name = gr.Radio(app.models, value=app.models[0], label='The STR model to use')
80
  with gr.Tabs():
81
  with gr.TabItem('Image Upload'):
82
- image_upload = gr.Image(type='pil', source='upload', label='Image')
83
  gr.Examples(glob.glob('demo_images/*.*'), inputs=image_upload)
84
  read_upload = gr.Button('Read Text')
85
  with gr.TabItem('Canvas Sketch'):
86
- image_canvas = gr.Image(type='pil', source='canvas', label='Sketch')
87
  read_canvas = gr.Button('Read Text')
88
 
89
  output = gr.Textbox(max_lines=1, label='Model output')
 
45
  def __call__(self, model_name, image):
46
  if image is None:
47
  return '', []
48
+ if isinstance(image, dict): # Extact image from ImageEditor output
49
+ image = image['composite']
50
  model = self._get_model(model_name)
51
  image = self._preprocess(image.convert('RGB')).unsqueeze(0)
52
  # Greedy decoding
 
81
  model_name = gr.Radio(app.models, value=app.models[0], label='The STR model to use')
82
  with gr.Tabs():
83
  with gr.TabItem('Image Upload'):
84
+ image_upload = gr.Image(type='pil', sources=['upload'], label='Image')
85
  gr.Examples(glob.glob('demo_images/*.*'), inputs=image_upload)
86
  read_upload = gr.Button('Read Text')
87
  with gr.TabItem('Canvas Sketch'):
88
+ image_canvas = gr.ImageEditor(type='pil', sources=[], label='Sketch', image_mode='RGB', layers=False, canvas_size=(768, 192))
89
  read_canvas = gr.Button('Read Text')
90
 
91
  output = gr.Textbox(max_lines=1, label='Model output')
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  --extra-index-url https://download.pytorch.org/whl/cpu
2
 
3
- gradio >=3.0.0, <4.0.0
4
  torch >=2.0.0
5
  torchvision >=0.15.0
6
  pytorch-lightning ~=2.2.0
 
1
  --extra-index-url https://download.pytorch.org/whl/cpu
2
 
3
+ gradio ~=4.36.0
4
  torch >=2.0.0
5
  torchvision >=0.15.0
6
  pytorch-lightning ~=2.2.0