Spaces:
Runtime error
Runtime error
# Import necessary libraries | |
import blurr | |
import gradio as gr | |
from pathlib import Path | |
from fastai.text.all import * | |
from blurr.text.data.all import * | |
from blurr.text.modeling.all import * | |
# Manually download and prepare SQuAD dataset | |
from datasets import load_dataset | |
squad = load_dataset("squad") | |
# Load the learner without using SQuAD | |
inf_learn = load_learner(fname=Path("laptop_summarizer_1.pkl"), trust_remote_code=True) | |
# Define a function to generate summaries using your model | |
def generate_summary(input_text): | |
prediction = inf_learn.blurr_generate(input_text) | |
generated_text = prediction[0]['generated_texts'] | |
return generated_text | |
# Create an interface for the model | |
interface = gr.Interface( | |
fn=generate_summary, # The function to generate summaries | |
inputs=gr.inputs.Textbox(), # Input field for text | |
outputs=gr.outputs.Textbox(), # Output field for generated text | |
live=True, # Whether to update results in real-time | |
title="Laptop Guru", # Title of the interface | |
description="Enter your requirements & get valuable insight from Guru." # Description of the interface | |
) | |
# Start the Gradio app | |
interface.launch(inline=True, trust_remote_code=True) | |