Spaces:
Runtime error
Runtime error
tdnathmlenthusiast
commited on
Commit
•
a5f5982
1
Parent(s):
026868a
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,33 @@
|
|
1 |
# Import necessary libraries
|
|
|
2 |
import gradio as gr
|
3 |
from pathlib import Path
|
4 |
from fastai.text.all import *
|
5 |
from blurr.text.data.all import *
|
6 |
from blurr.text.modeling.all import *
|
7 |
|
8 |
-
#
|
|
|
|
|
|
|
|
|
9 |
inf_learn = load_learner(fname=Path("laptop_summarizer_1.pkl"), trust_remote_code=True)
|
10 |
|
11 |
# Define a function to generate summaries using your model
|
12 |
def generate_summary(input_text):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
# Create an interface for the model
|
18 |
interface = gr.Interface(
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
)
|
26 |
|
27 |
# Start the Gradio app
|
28 |
-
interface.launch(inline=True)
|
|
|
1 |
# Import necessary libraries
|
2 |
+
import blurr
|
3 |
import gradio as gr
|
4 |
from pathlib import Path
|
5 |
from fastai.text.all import *
|
6 |
from blurr.text.data.all import *
|
7 |
from blurr.text.modeling.all import *
|
8 |
|
9 |
+
# Manually download and prepare SQuAD dataset
|
10 |
+
from datasets import load_dataset
|
11 |
+
squad = load_dataset("squad")
|
12 |
+
|
13 |
+
# Load the learner without using SQuAD
|
14 |
inf_learn = load_learner(fname=Path("laptop_summarizer_1.pkl"), trust_remote_code=True)
|
15 |
|
16 |
# Define a function to generate summaries using your model
|
17 |
def generate_summary(input_text):
|
18 |
+
prediction = inf_learn.blurr_generate(input_text)
|
19 |
+
generated_text = prediction[0]['generated_texts']
|
20 |
+
return generated_text
|
21 |
|
22 |
# Create an interface for the model
|
23 |
interface = gr.Interface(
|
24 |
+
fn=generate_summary, # The function to generate summaries
|
25 |
+
inputs=gr.inputs.Textbox(), # Input field for text
|
26 |
+
outputs=gr.outputs.Textbox(), # Output field for generated text
|
27 |
+
live=True, # Whether to update results in real-time
|
28 |
+
title="Laptop Guru", # Title of the interface
|
29 |
+
description="Enter your requirements & get valuable insight from Guru." # Description of the interface
|
30 |
)
|
31 |
|
32 |
# Start the Gradio app
|
33 |
+
interface.launch(inline=True, trust_remote_code=True)
|