Spaces:
Runtime error
Runtime error
Commit
Β·
898db10
1
Parent(s):
b9e2969
initial commit
Browse files- .github/workflows/main.yml +23 -0
- main.py +22 -0
.github/workflows/main.yml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Sync to Hugging Face hub
|
2 |
+
on:
|
3 |
+
push:
|
4 |
+
branches: [main]
|
5 |
+
|
6 |
+
# to run this workflow manually from the Actions tab
|
7 |
+
workflow_dispatch:
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
sync-to-hub:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
steps:
|
13 |
+
- uses: actions/checkout@v2
|
14 |
+
with:
|
15 |
+
fetch-depth: 0
|
16 |
+
- name: Add remote
|
17 |
+
env:
|
18 |
+
HF: ${{ secrets.HG }}
|
19 |
+
run: git remote add space https://noahgift:[email protected]/spaces/noahgift/demo
|
20 |
+
- name: Push to hub
|
21 |
+
env:
|
22 |
+
HF: ${{ secrets.HG }}
|
23 |
+
run: git push --force https://huggingface.co/spaces/Abdulrhman37/mlops_text_summarizer main
|
main.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the summarization pipeline
|
5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
6 |
+
|
7 |
+
# Define the summarization function
|
8 |
+
def summarize_text(article):
|
9 |
+
summary = summarizer(article, max_length=130, min_length=30, do_sample=False)
|
10 |
+
return summary[0]['summary_text']
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=summarize_text,
|
15 |
+
inputs="textbox", # User inputs a large article
|
16 |
+
outputs="text", # Output is the summary of the article
|
17 |
+
title="Text Summarizer",
|
18 |
+
description="Enter an article to get a summarized version."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the Gradio app
|
22 |
+
interface.launch()
|