Port to interactive_pipe 0.9.4 (context proxy) and gradio 6
Browse files- apply_classifier / display_result use the `context` proxy instead of a
`context={}` keyword argument (removed in interactive_pipe 0.9.0)
- requirements.txt: pin interactive-pipe==0.9.4
- README.md: sdk_version 6.32.0 (current gradio), python_version 3.12
- README.md +2 -1
- app.py +2 -3
- requirements.txt +2 -2
README.md
CHANGED
|
@@ -4,7 +4,8 @@ emoji: 🎓
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
short_description: classification example using interactive pipe
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.32.0
|
| 8 |
+
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
short_description: classification example using interactive pipe
|
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
| 3 |
import argparse
|
| 4 |
from PIL import Image
|
| 5 |
from interactive_pipe import (
|
| 6 |
-
interactive_pipeline, interactive, Curve, SingleCurve
|
| 7 |
)
|
| 8 |
from transformers import pipeline
|
| 9 |
|
|
@@ -98,7 +98,6 @@ def add_noise(img: np.ndarray, noise_level: float = 0., seed: int = 42):
|
|
| 98 |
@interactive(detect=(True, "Enable classification"))
|
| 99 |
def apply_classifier(
|
| 100 |
img: np.ndarray,
|
| 101 |
-
context: dict = {},
|
| 102 |
detect: bool = False
|
| 103 |
) -> None:
|
| 104 |
if detect:
|
|
@@ -121,7 +120,7 @@ def apply_classifier(
|
|
| 121 |
context["result"] = result
|
| 122 |
|
| 123 |
|
| 124 |
-
def display_result(
|
| 125 |
# Context is shared between all interactive blocks.
|
| 126 |
# We can access the classification result here.
|
| 127 |
result_dict = context.get("result", [])
|
|
|
|
| 3 |
import argparse
|
| 4 |
from PIL import Image
|
| 5 |
from interactive_pipe import (
|
| 6 |
+
interactive_pipeline, interactive, Curve, SingleCurve, context
|
| 7 |
)
|
| 8 |
from transformers import pipeline
|
| 9 |
|
|
|
|
| 98 |
@interactive(detect=(True, "Enable classification"))
|
| 99 |
def apply_classifier(
|
| 100 |
img: np.ndarray,
|
|
|
|
| 101 |
detect: bool = False
|
| 102 |
) -> None:
|
| 103 |
if detect:
|
|
|
|
| 120 |
context["result"] = result
|
| 121 |
|
| 122 |
|
| 123 |
+
def display_result() -> Curve:
|
| 124 |
# Context is shared between all interactive blocks.
|
| 125 |
# We can access the classification result here.
|
| 126 |
result_dict = context.get("result", [])
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
interactive-pipe
|
| 2 |
torch>=2.0.0
|
| 3 |
-
transformers
|
|
|
|
| 1 |
+
interactive-pipe==0.9.4
|
| 2 |
torch>=2.0.0
|
| 3 |
+
transformers
|