Spaces:
Sleeping
Sleeping
fixing ./app.py
Browse files- Makefile +2 -1
- app.py +16 -6
- requirements.txt +1 -0
Makefile
CHANGED
|
@@ -4,7 +4,8 @@ install:
|
|
| 4 |
test :
|
| 5 |
python -m pytest -vv -- cov=hello -- cov=greeting \
|
| 6 |
-cov=smath -cov=web tests
|
| 7 |
-
python -m pytest -- nbval notebook.
|
|
|
|
| 8 |
#python -m pytest -v tests/test_web.py #if you just want to test web
|
| 9 |
|
| 10 |
debug:
|
|
|
|
| 4 |
test :
|
| 5 |
python -m pytest -vv -- cov=hello -- cov=greeting \
|
| 6 |
-cov=smath -cov=web tests
|
| 7 |
+
python -m pytest -- nbval notebook.ipynb
|
| 8 |
+
#tests our jupyter notebook
|
| 9 |
#python -m pytest -v tests/test_web.py #if you just want to test web
|
| 10 |
|
| 11 |
debug:
|
app.py
CHANGED
|
@@ -1,14 +1,24 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def predict(prompt):
|
| 7 |
-
summary = model(prompt)
|
| 8 |
return summary
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
demo.
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Use a specific model and CPU
|
| 5 |
+
model = pipeline(
|
| 6 |
+
"summarization",
|
| 7 |
+
model="facebook/bart-large-cnn",
|
| 8 |
+
device=-1 # forces CPU
|
| 9 |
+
)
|
| 10 |
|
| 11 |
def predict(prompt):
|
| 12 |
+
summary = model(prompt)[0]["summary_text"]
|
| 13 |
return summary
|
| 14 |
|
| 15 |
+
# Simple Gradio interface
|
| 16 |
+
demo = gr.Interface(
|
| 17 |
+
fn=predict,
|
| 18 |
+
inputs=gr.Textbox(placeholder="Enter text to summarize", lines=4),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="MLOps Pipeline Summarizer",
|
| 21 |
+
description="Enter text and get a summarized version using Hugging Face Transformers"
|
| 22 |
+
)
|
| 23 |
|
| 24 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
gradio == 6.2.0
|
| 2 |
transformers == 4.57.3
|
| 3 |
tensorflow ==2.20.0
|
|
|
|
|
|
| 1 |
gradio == 6.2.0
|
| 2 |
transformers == 4.57.3
|
| 3 |
tensorflow ==2.20.0
|
| 4 |
+
torch
|