Spaces:
Runtime error
Runtime error
tdnathmlenthusiast
commited on
Commit
•
715b816
1
Parent(s):
27c7519
actual code deployed
Browse files
app.py
CHANGED
@@ -1,26 +1,35 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
import
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
18 |
iface = gr.Interface(
|
19 |
-
fn=
|
20 |
-
inputs=gr.inputs.
|
21 |
-
outputs=gr.outputs.
|
22 |
-
live=True
|
|
|
|
|
|
|
23 |
)
|
24 |
|
25 |
-
#
|
26 |
-
iface.launch()
|
|
|
1 |
+
|
2 |
+
|
3 |
+
# Import necessary libraries
|
4 |
import gradio as gr
|
5 |
+
from pathlib import Path
|
6 |
+
from fastai.text.all import *
|
7 |
+
from blurr.text.data.all import *
|
8 |
+
from blurr.text.modeling.all import *
|
9 |
+
import pathlib
|
10 |
+
|
11 |
+
# Load the learner
|
12 |
+
inf_learn = load_learner(fname=Path("laptop_summarizer_1.pkl"))
|
13 |
+
|
14 |
+
# Define a function to generate summaries using your model
|
15 |
+
|
16 |
+
|
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 |
+
|
23 |
+
# Create an interface for the model
|
24 |
iface = gr.Interface(
|
25 |
+
fn=generate_summary, # The function to generate summaries
|
26 |
+
inputs=gr.inputs.Textbox(), # Input field for text
|
27 |
+
outputs=gr.outputs.Textbox(), # Output field for generated text
|
28 |
+
live=True, # Whether to update results in real-time
|
29 |
+
title="Laptop Guru", # Title of the interface
|
30 |
+
# Description of the interface
|
31 |
+
description="Enter your requirements & get valuable insight from Guru."
|
32 |
)
|
33 |
|
34 |
+
# Start the Gradio app
|
35 |
+
iface.launch(inline=False)
|