Shangkhonil commited on
Commit
b8a57f3
·
verified ·
1 Parent(s): d1d4d1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -15
app.py CHANGED
@@ -1,23 +1,27 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Initialize the audio classification pipeline with the MIT model
5
- pipe = pipeline("audio-classification", model="MIT/ast-finetuned-audioset-10-10-0.4593")
6
 
7
- # Define the function to classify an audio file
8
- def classify_audio(audio):
9
- result = pipe(audio)
10
- return {label['label']: label['score'] for label in result}
11
 
12
- # Set up the Gradio interface
13
- app = gr.Interface(
14
- fn=classify_audio, # Function to classify audio
15
- inputs=gr.Audio(), # Input for uploading an audio file (no 'source' or 'type' needed)
16
- outputs=gr.Label(num_top_classes=3), # Output with top 3 classification results
17
- title="Audio Classification", # App title
18
- description="Upload an audio file to classify it using MIT's fine-tuned AudioSet model."
 
 
 
 
19
  )
20
 
21
- # Launch the app
22
  if __name__ == "__main__":
23
- app.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the summarization pipeline with the BART model
5
+ pipe = pipeline("summarization", model="facebook/bart-large-cnn")
6
 
7
+ def summarize_text(text):
8
+ # Use the summarization pipeline to summarize the input text
9
+ summary = pipe(text, max_length=150, min_length=40, do_sample=False)
10
+ return summary[0]['summary_text']
11
 
12
+ # Gradio interface setup
13
+ title = "Text Summarization with BART"
14
+ description = "Provide a block of text, and the BART model will summarize it."
15
+
16
+ # Create Gradio interface
17
+ interface = gr.Interface(
18
+ fn=summarize_text,
19
+ inputs=gr.Textbox(lines=10, label="Input Text"),
20
+ outputs=gr.Textbox(label="Summarized Text"),
21
+ title=title,
22
+ description=description,
23
  )
24
 
25
+ # Launch the Gradio app
26
  if __name__ == "__main__":
27
+ interface.launch()