Rimi98 commited on
Commit
90d99db
1 Parent(s): c2024d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -4,12 +4,22 @@ from transformers import AutoTokenizer
4
  import torch
5
  import os
6
  from transformers import pipeline
 
 
 
 
 
 
 
 
 
7
  ### --- Audio/Video to txt ---###
8
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
9
  pipe = pipeline("automatic-speech-recognition",
10
  model="openai/whisper-base.en",
11
  chunk_length_s=30, device=device)
12
 
 
13
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn", device=device)
14
 
15
 
@@ -40,18 +50,6 @@ def summary(text):
40
  summ = summarizer(chunks,max_length = 100)
41
 
42
  return summ
43
-
44
-
45
-
46
-
47
-
48
- token = AutoTokenizer.from_pretrained('distilroberta-base')
49
-
50
- inf_session = onnxruntime.InferenceSession('classifier1-quantized.onnx')
51
- input_name = inf_session.get_inputs()[0].name
52
- output_name = inf_session.get_outputs()[0].name
53
-
54
- classes = ['Art', 'Astrology', 'Biology', 'Chemistry', 'Economics', 'History', 'Literature', 'Philosophy', 'Physics', 'Politics', 'Psychology', 'Sociology']
55
 
56
  def classify(vid):
57
  full_text = video_identity(vid)
@@ -64,9 +62,9 @@ def classify(vid):
64
  probs = torch.sigmoid(logits)[0]
65
  return full_text, sum, dict(zip(classes,map(float,probs)))
66
 
67
- # label = gr.outputs.Label(num_top_classes=5)
68
  iface = gr.Interface(fn=classify,
69
- inputs=gr.inputs.Audio(source="upload", type="filepath"),
70
  outputs = ['text','text',gr.outputs.Label(num_top_classes=3)])
71
  iface.launch(inline=False)
72
 
 
4
  import torch
5
  import os
6
  from transformers import pipeline
7
+
8
+ token = AutoTokenizer.from_pretrained('distilroberta-base')
9
+
10
+ inf_session = onnxruntime.InferenceSession('classifier1-quantized.onnx')
11
+ input_name = inf_session.get_inputs()[0].name
12
+ output_name = inf_session.get_outputs()[0].name
13
+
14
+ classes = ['Art', 'Astrology', 'Biology', 'Chemistry', 'Economics', 'History', 'Literature', 'Philosophy', 'Physics', 'Politics', 'Psychology', 'Sociology']
15
+
16
  ### --- Audio/Video to txt ---###
17
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
18
  pipe = pipeline("automatic-speech-recognition",
19
  model="openai/whisper-base.en",
20
  chunk_length_s=30, device=device)
21
 
22
+ ### --- Text Summary --- ###
23
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn", device=device)
24
 
25
 
 
50
  summ = summarizer(chunks,max_length = 100)
51
 
52
  return summ
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  def classify(vid):
55
  full_text = video_identity(vid)
 
62
  probs = torch.sigmoid(logits)[0]
63
  return full_text, sum, dict(zip(classes,map(float,probs)))
64
 
65
+
66
  iface = gr.Interface(fn=classify,
67
+ inputs=gr.inputs.Audio(source="upload", type="filepath",label="Model Card"),
68
  outputs = ['text','text',gr.outputs.Label(num_top_classes=3)])
69
  iface.launch(inline=False)
70