Pierre Chapuis commited on
bump deps
Browse files- README.md +2 -2
- pyproject.toml +3 -2
- requirements.txt +2 -1
- src/app.py +11 -7
- uv.lock +0 -0
README.md
CHANGED
|
@@ -4,8 +4,8 @@ emoji: ✂️
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: 3.12
|
| 9 |
app_file: src/app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.20.0
|
| 8 |
+
python_version: 3.12.12
|
| 9 |
app_file: src/app.py
|
| 10 |
pinned: false
|
| 11 |
license: mit
|
pyproject.toml
CHANGED
|
@@ -6,10 +6,11 @@ authors = [
|
|
| 6 |
{ name = "Pierre Chapuis", email = "pierre@lagon.tech" }
|
| 7 |
]
|
| 8 |
dependencies = [
|
| 9 |
-
"gradio>=
|
| 10 |
-
"gradio-image-annotation>=0.4.1
|
| 11 |
"pillow>=11.3.0",
|
| 12 |
"pi-heif>=1.1.0",
|
|
|
|
| 13 |
"refiners @ git+https://github.com/finegrain-ai/refiners",
|
| 14 |
"numba>=0.60.0",
|
| 15 |
"pymatting>=1.1.12",
|
|
|
|
| 6 |
{ name = "Pierre Chapuis", email = "pierre@lagon.tech" }
|
| 7 |
]
|
| 8 |
dependencies = [
|
| 9 |
+
"gradio>=6.20.0",
|
| 10 |
+
"gradio-image-annotation>=0.4.1",
|
| 11 |
"pillow>=11.3.0",
|
| 12 |
"pi-heif>=1.1.0",
|
| 13 |
+
"torch==2.11.0",
|
| 14 |
"refiners @ git+https://github.com/finegrain-ai/refiners",
|
| 15 |
"numba>=0.60.0",
|
| 16 |
"pymatting>=1.1.12",
|
requirements.txt
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
spaces>=0.35.0
|
| 2 |
-
gradio_image_annotation>=0.4.1
|
| 3 |
pillow>=11.3.0
|
| 4 |
pi_heif>=1.1.0
|
|
|
|
| 5 |
git+https://github.com/finegrain-ai/refiners@cfe8b66ba4f8a906583850ac25e9e89cb83a44b9
|
| 6 |
numba>=0.60.0
|
| 7 |
pymatting>=1.1.12
|
|
|
|
| 1 |
spaces>=0.35.0
|
| 2 |
+
gradio_image_annotation>=0.4.1
|
| 3 |
pillow>=11.3.0
|
| 4 |
pi_heif>=1.1.0
|
| 5 |
+
torch==2.11.0
|
| 6 |
git+https://github.com/finegrain-ai/refiners@cfe8b66ba4f8a906583850ac25e9e89cb83a44b9
|
| 7 |
numba>=0.60.0
|
| 8 |
pymatting>=1.1.12
|
src/app.py
CHANGED
|
@@ -56,7 +56,9 @@ def gd_detect(img: Image.Image, prompt: str) -> BoundingBox | None:
|
|
| 56 |
assert isinstance(gd_processor, GroundingDinoProcessor)
|
| 57 |
|
| 58 |
# Grounding Dino expects a dot after each category.
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
with no_grad():
|
| 62 |
outputs = gd_model(**inputs)
|
|
@@ -167,7 +169,7 @@ def process_bbox(prompts: dict[str, Any]) -> tuple[tuple[Image.Image, Image.Imag
|
|
| 167 |
return _process(img, bbox)
|
| 168 |
|
| 169 |
|
| 170 |
-
def on_change_bbox(prompts: dict[str, Any] | None):
|
| 171 |
return gr.update(interactive=prompts is not None)
|
| 172 |
|
| 173 |
|
|
@@ -175,7 +177,7 @@ def process_prompt(img: Image.Image, prompt: str) -> tuple[tuple[Image.Image, Im
|
|
| 175 |
return _process(img, prompt)
|
| 176 |
|
| 177 |
|
| 178 |
-
def on_change_prompt(img: Image.Image | None, prompt: str | None):
|
| 179 |
return gr.update(interactive=bool(img and prompt))
|
| 180 |
|
| 181 |
|
|
@@ -184,9 +186,11 @@ TITLE = """
|
|
| 184 |
<p>
|
| 185 |
Create HD cutouts from any image with just a prompt.
|
| 186 |
</p><p>
|
| 187 |
-
This Space showcases one of Finegrain's earlier generative AI models. Today, we're building the Agentic Camera:
|
|
|
|
| 188 |
</p><p>
|
| 189 |
-
✨ Learn more at <a href="https://finegrain.ai">finegrain.ai</a>
|
|
|
|
| 190 |
</p>
|
| 191 |
"""
|
| 192 |
|
|
@@ -201,7 +205,7 @@ with gr.Blocks() as demo:
|
|
| 201 |
prompt = gr.Textbox(label="What should we cut?")
|
| 202 |
btn = gr.ClearButton(value="Cut Out Object", interactive=False)
|
| 203 |
with gr.Column():
|
| 204 |
-
oimg = gr.ImageSlider(label="Before / After", max_height=1500,
|
| 205 |
dlbt = gr.DownloadButton("Download Cutout", interactive=False)
|
| 206 |
|
| 207 |
btn.add(oimg)
|
|
@@ -255,7 +259,7 @@ with gr.Blocks() as demo:
|
|
| 255 |
)
|
| 256 |
btn = gr.ClearButton(value="Cut Out Object", interactive=False)
|
| 257 |
with gr.Column():
|
| 258 |
-
oimg = gr.ImageSlider(label="Before / After", max_height=1500,
|
| 259 |
dlbt = gr.DownloadButton("Download Cutout", interactive=False)
|
| 260 |
|
| 261 |
btn.add(oimg)
|
|
|
|
| 56 |
assert isinstance(gd_processor, GroundingDinoProcessor)
|
| 57 |
|
| 58 |
# Grounding Dino expects a dot after each category.
|
| 59 |
+
# transformers 5 accepts return_tensors at runtime but omits it from the typed processor kwargs.
|
| 60 |
+
processor_kwargs: dict[str, Any] = {"return_tensors": "pt"}
|
| 61 |
+
inputs = gd_processor(images=img, text=f"{prompt}.", **processor_kwargs).to(device=device)
|
| 62 |
|
| 63 |
with no_grad():
|
| 64 |
outputs = gd_model(**inputs)
|
|
|
|
| 169 |
return _process(img, bbox)
|
| 170 |
|
| 171 |
|
| 172 |
+
def on_change_bbox(prompts: dict[str, Any] | None) -> dict[str, Any]:
|
| 173 |
return gr.update(interactive=prompts is not None)
|
| 174 |
|
| 175 |
|
|
|
|
| 177 |
return _process(img, prompt)
|
| 178 |
|
| 179 |
|
| 180 |
+
def on_change_prompt(img: Image.Image | None, prompt: str | None) -> dict[str, Any]:
|
| 181 |
return gr.update(interactive=bool(img and prompt))
|
| 182 |
|
| 183 |
|
|
|
|
| 186 |
<p>
|
| 187 |
Create HD cutouts from any image with just a prompt.
|
| 188 |
</p><p>
|
| 189 |
+
This Space showcases one of Finegrain's earlier generative AI models. Today, we're building the Agentic Camera:
|
| 190 |
+
an on-device system that produces the intended photo at capture time, eliminating image editing in most cases.
|
| 191 |
</p><p>
|
| 192 |
+
✨ Learn more at <a href="https://finegrain.ai">finegrain.ai</a>
|
| 193 |
+
or follow <a href="https://huggingface.co/finegrain">Finegrain</a> for updates.
|
| 194 |
</p>
|
| 195 |
"""
|
| 196 |
|
|
|
|
| 205 |
prompt = gr.Textbox(label="What should we cut?")
|
| 206 |
btn = gr.ClearButton(value="Cut Out Object", interactive=False)
|
| 207 |
with gr.Column():
|
| 208 |
+
oimg = gr.ImageSlider(label="Before / After", max_height=1500, buttons=["download"])
|
| 209 |
dlbt = gr.DownloadButton("Download Cutout", interactive=False)
|
| 210 |
|
| 211 |
btn.add(oimg)
|
|
|
|
| 259 |
)
|
| 260 |
btn = gr.ClearButton(value="Cut Out Object", interactive=False)
|
| 261 |
with gr.Column():
|
| 262 |
+
oimg = gr.ImageSlider(label="Before / After", max_height=1500, buttons=["download"])
|
| 263 |
dlbt = gr.DownloadButton("Download Cutout", interactive=False)
|
| 264 |
|
| 265 |
btn.add(oimg)
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|