JohnKouf commited on
Commit
1b33daa
·
verified ·
1 Parent(s): 155660f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -9,6 +9,14 @@ tokenizer = AutoTokenizer.from_pretrained("kriton/greek-text-summarization")
9
  model = AutoModelForSeq2SeqLM.from_pretrained("kriton/greek-text-summarization")
10
  generator = pipeline("summarization", model="kriton/greek-text-summarization")
11
 
 
 
 
 
 
 
 
 
12
  def genarate_summary(article):
13
  inputs = tokenizer(
14
  'summarize: ' + article,
@@ -30,19 +38,14 @@ def genarate_summary(article):
30
 
31
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
32
 
33
-
34
-
35
- def generate_text(prompt):
36
- response = generator(generate_summary(prompt), max_length=512, num_return_sequences=1)
37
- return response[0]["generated_text"]
38
-
39
  iface = gr.Interface(
40
- fn=generate_text,
41
- inputs="text",
42
  outputs="text",
43
- title="Remote LLM Text Generation",
44
- description="Enter a prompt to generate text from the model."
45
  )
46
 
47
- # Launch the Gradio interface
48
- iface.launch(share=True)
 
9
  model = AutoModelForSeq2SeqLM.from_pretrained("kriton/greek-text-summarization")
10
  generator = pipeline("summarization", model="kriton/greek-text-summarization")
11
 
12
+ import gradio as gr
13
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
14
+
15
+ # Load the model and tokenizer
16
+ tokenizer = AutoTokenizer.from_pretrained("kriton/greek-text-summarization")
17
+ model = AutoModelForSeq2SeqLM.from_pretrained("kriton/greek-text-summarization")
18
+
19
+ # Define the summary generation function
20
  def genarate_summary(article):
21
  inputs = tokenizer(
22
  'summarize: ' + article,
 
38
 
39
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
40
 
41
+ # Set up Gradio Interface
 
 
 
 
 
42
  iface = gr.Interface(
43
+ fn=genarate_summary,
44
+ inputs="text",
45
  outputs="text",
46
+ title="Greek Text Summarizer",
47
+ description="Enter an article in Greek, and this tool will generate a summary."
48
  )
49
 
50
+ # Launch the Gradio Interface
51
+ iface.launch()