Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
with gr.Blocks() as demo:
|
| 6 |
+
gr.Markdown("## 🐇 Transformers Pipeline Playground")
|
| 7 |
+
gr.Markdown(
|
| 8 |
+
"Search for a model on the Hub en explore its output performance on CPU. Some interesting categories are [Text Classification](https://huggingface.co/models?pipeline_tag=image-classification&sort=trending), [Token Classification](https://huggingface.co/models?pipeline_tag=token-classification&sort=trending), [Question Answering](https://huggingface.co/models?pipeline_tag=question-answering&sort=trending) or [Image Classification](https://huggingface.co/models?pipeline_tag=image-classification&sort=trending)."
|
| 9 |
+
)
|
| 10 |
+
search_in = HuggingfaceHubSearch(
|
| 11 |
+
label="Hub Search",
|
| 12 |
+
placeholder="Search for a model",
|
| 13 |
+
search_type="model",
|
| 14 |
+
sumbit_on_select=True,
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
@gr.render(inputs=[search_in], triggers=[search_in.submit])
|
| 18 |
+
def get_interface_from_repo(repo_id: str, progress: gr.Progress = gr.Progress()):
|
| 19 |
+
progress(0.0, desc="Loading model")
|
| 20 |
+
pipe = pipeline(model=repo_id)
|
| 21 |
+
progress(1.0, desc="Model loaded")
|
| 22 |
+
gr.Interface.from_pipeline(pipe)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
demo.launch()
|