testkeyword / app.py
ghaithoun's picture
Update app.py
d197442 verified
raw
history blame contribute delete
817 Bytes
from keybert import KeyBERT
import gradio as gr
# Initialize KeyBERT model
kw_model = KeyBERT()
# Define Gradio interface function
def gradio_interface(doc):
# Use KeyBERT model to extract keywords from the input text
keywords = kw_model.extract_keywords(doc)
return keywords
# Set up Gradio interface
iface = gr.Interface(
fn=gradio_interface, # Function to process the input
inputs=gr.Textbox(label="Document", lines=3, placeholder="Enter the document here..."), # Textbox input for the document
outputs="json", # Output format (JSON to display extracted keywords)
title="Keyword Extraction Tool v1", # Title of the Gradio app
description="Extracts keywords from a given document using KeyBERT." # Description of the app
)
# Launch Gradio interface
iface.launch(share=True)