Pierre Chapuis commited on
Commit
2a8bb88
·
unverified ·
1 Parent(s): 218692b

simplify - see https://github.com/gradio-app/gradio/pull/9011

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +21 -6
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🧽
4
  colorFrom: gray
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.39.0
8
  app_file: app.py
9
  pinned: false
10
  license: other
 
4
  colorFrom: gray
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 4.41.0
8
  app_file: app.py
9
  pinned: false
10
  license: other
app.py CHANGED
@@ -18,7 +18,7 @@ with env.prefixed("ERASER_"):
18
  auth = None if API_KEY is None else httpx.BasicAuth("hf", API_KEY)
19
 
20
 
21
- def process_bbox(prompts: dict[str, Any], request: gr.Request) -> Image.Image:
22
  assert isinstance(img := prompts["image"], Image.Image)
23
  assert isinstance(boxes := prompts["boxes"], list)
24
  assert len(boxes) == 1
@@ -47,7 +47,11 @@ def on_change_bbox(prompts: dict[str, Any]):
47
  return gr.update(interactive=len(prompts["boxes"]) > 0)
48
 
49
 
50
- def process_prompt(img: Image.Image, prompt: str, request: gr.Request) -> Image.Image:
 
 
 
 
51
  data = {"prompt": prompt}
52
  headers = {}
53
  if request: # avoid DOS - can be None despite type hint!
@@ -79,10 +83,21 @@ TITLE = """
79
  Object Eraser Powered By Refiners
80
  </h1>
81
 
82
- <div style="display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 1.25rem; flex-wrap: wrap;">
 
 
 
 
 
 
 
 
83
  <a href="https://github.com/finegrain-ai/refiners" target="_blank">[Refiners]</a>
84
  <a href="https://finegrain.ai/" target="_blank">[Finegrain]</a>
85
- <a href="https://huggingface.co/spaces/finegrain/finegrain-image-enhancer" target="_blank">[Finegrain Image Enhancer]</a>
 
 
 
86
  </div>
87
 
88
  <p>
@@ -162,7 +177,7 @@ with gr.Blocks() as demo:
162
  ]
163
 
164
  ex = gr.Examples(
165
- examples=[x + [None] for x in examples],
166
  inputs=[iimg, prompt],
167
  outputs=[oimg],
168
  fn=process_prompt,
@@ -231,7 +246,7 @@ with gr.Blocks() as demo:
231
  ]
232
 
233
  ex = gr.Examples(
234
- examples=[[x, None] for x in examples],
235
  inputs=[annotator],
236
  outputs=[oimg],
237
  fn=process_bbox,
 
18
  auth = None if API_KEY is None else httpx.BasicAuth("hf", API_KEY)
19
 
20
 
21
+ def process_bbox(prompts: dict[str, Any], request: gr.Request | None) -> Image.Image:
22
  assert isinstance(img := prompts["image"], Image.Image)
23
  assert isinstance(boxes := prompts["boxes"], list)
24
  assert len(boxes) == 1
 
47
  return gr.update(interactive=len(prompts["boxes"]) > 0)
48
 
49
 
50
+ def process_prompt(
51
+ img: Image.Image,
52
+ prompt: str,
53
+ request: gr.Request | None,
54
+ ) -> Image.Image:
55
  data = {"prompt": prompt}
56
  headers = {}
57
  if request: # avoid DOS - can be None despite type hint!
 
83
  Object Eraser Powered By Refiners
84
  </h1>
85
 
86
+ <div style="
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ gap: 0.5rem;
91
+ margin-bottom: 0.5rem;
92
+ font-size: 1.25rem;
93
+ flex-wrap: wrap;
94
+ ">
95
  <a href="https://github.com/finegrain-ai/refiners" target="_blank">[Refiners]</a>
96
  <a href="https://finegrain.ai/" target="_blank">[Finegrain]</a>
97
+ <a
98
+ href="https://huggingface.co/spaces/finegrain/finegrain-image-enhancer"
99
+ target="_blank"
100
+ >[Finegrain Image Enhancer]</a>
101
  </div>
102
 
103
  <p>
 
177
  ]
178
 
179
  ex = gr.Examples(
180
+ examples=examples,
181
  inputs=[iimg, prompt],
182
  outputs=[oimg],
183
  fn=process_prompt,
 
246
  ]
247
 
248
  ex = gr.Examples(
249
+ examples=examples,
250
  inputs=[annotator],
251
  outputs=[oimg],
252
  fn=process_bbox,