Spaces:
Runtime error
Runtime error
Change HF entry point and add examples
Browse files- README.md +3 -1
- app.py +1 -1
- app/cli.py +4 -1
- app/gui.py +9 -3
README.md
CHANGED
|
@@ -6,11 +6,13 @@ colorTo: green
|
|
| 6 |
pinned: false
|
| 7 |
sdk: gradio
|
| 8 |
python_version: 3.11
|
| 9 |
-
app_file: app.py
|
| 10 |
datasets:
|
| 11 |
- mrshu/amazonreviews
|
| 12 |
- stanfordnlp/sentiment140
|
| 13 |
- stanfordnlp/imdb
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
# Sentiment Analysis
|
|
|
|
| 6 |
pinned: false
|
| 7 |
sdk: gradio
|
| 8 |
python_version: 3.11
|
| 9 |
+
app_file: app/gui.py
|
| 10 |
datasets:
|
| 11 |
- mrshu/amazonreviews
|
| 12 |
- stanfordnlp/sentiment140
|
| 13 |
- stanfordnlp/imdb
|
| 14 |
+
models:
|
| 15 |
+
- spacy/en_core_web_sm
|
| 16 |
---
|
| 17 |
|
| 18 |
# Sentiment Analysis
|
app.py
CHANGED
|
@@ -2,4 +2,4 @@
|
|
| 2 |
|
| 3 |
from app.gui import launch_gui
|
| 4 |
|
| 5 |
-
launch_gui(
|
|
|
|
| 2 |
|
| 3 |
from app.gui import launch_gui
|
| 4 |
|
| 5 |
+
launch_gui(share=False)
|
app/cli.py
CHANGED
|
@@ -29,9 +29,12 @@ def cli() -> None: ...
|
|
| 29 |
)
|
| 30 |
def gui(model_path: Path, share: bool) -> None:
|
| 31 |
"""Launch the Gradio GUI"""
|
|
|
|
|
|
|
| 32 |
from app.gui import launch_gui
|
| 33 |
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@cli.command()
|
|
|
|
| 29 |
)
|
| 30 |
def gui(model_path: Path, share: bool) -> None:
|
| 31 |
"""Launch the Gradio GUI"""
|
| 32 |
+
import os
|
| 33 |
+
|
| 34 |
from app.gui import launch_gui
|
| 35 |
|
| 36 |
+
os.environ["MODEL_PATH"] = model_path.as_posix()
|
| 37 |
+
launch_gui(share)
|
| 38 |
|
| 39 |
|
| 40 |
@cli.command()
|
app/gui.py
CHANGED
|
@@ -42,15 +42,21 @@ def sentiment_analysis(text: str) -> str:
|
|
| 42 |
|
| 43 |
demo = gr.Interface(
|
| 44 |
fn=sentiment_analysis,
|
| 45 |
-
inputs="text",
|
| 46 |
outputs="label",
|
| 47 |
title="Sentiment Analysis",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
)
|
| 49 |
|
| 50 |
|
| 51 |
-
def launch_gui(
|
| 52 |
"""Launch the Gradio GUI."""
|
| 53 |
-
os.environ["MODEL_PATH"] = model_path
|
| 54 |
demo.launch(share=share)
|
| 55 |
|
| 56 |
|
|
|
|
| 42 |
|
| 43 |
demo = gr.Interface(
|
| 44 |
fn=sentiment_analysis,
|
| 45 |
+
inputs=gr.Textbox(lines=10, label="Enter text here"),
|
| 46 |
outputs="label",
|
| 47 |
title="Sentiment Analysis",
|
| 48 |
+
description="Predict the sentiment of a given text.",
|
| 49 |
+
examples=[
|
| 50 |
+
["I love the weather today!"],
|
| 51 |
+
["You are a terrible person."],
|
| 52 |
+
["The movie we watched was boring."],
|
| 53 |
+
["This website is amazing!"],
|
| 54 |
+
],
|
| 55 |
)
|
| 56 |
|
| 57 |
|
| 58 |
+
def launch_gui(share: bool) -> None:
|
| 59 |
"""Launch the Gradio GUI."""
|
|
|
|
| 60 |
demo.launch(share=share)
|
| 61 |
|
| 62 |
|