Naman Pundir
commited on
Commit
·
150c844
1
Parent(s):
8ba0e95
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
# Load the text summarization model
|
5 |
+
model_name = "Aiyan99/Theus_eleuther_1.3B_concepttagging"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
# Define the Gradio interface
|
10 |
+
def summarize_text(input_text):
|
11 |
+
# Tokenize and generate summary
|
12 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt", max_length=1024, truncation=True)
|
13 |
+
summary_ids = model.generate(input_ids, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
|
14 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
15 |
+
return summary
|
16 |
+
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=summarize_text,
|
19 |
+
inputs="text",
|
20 |
+
outputs="text",
|
21 |
+
title="Concept Tagger",
|
22 |
+
description="Concept tag your text using Aiyan99's Theus model (1.3B Concept Tagging).",
|
23 |
+
)
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
iface.launch()
|