runaksh commited on
Commit
52b1f5b
·
1 Parent(s): 871a74b

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -54
app.py DELETED
@@ -1,54 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from PIL import Image
4
- from timeit import default_timer as timer
5
- from tensorflow import keras
6
- import torch
7
- from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
8
- import numpy as np
9
-
10
- username = "runaksh"
11
- repo_name = "finetuned-sentiment-model"
12
- repo_path = username+ '/' + repo_name
13
- model_1 = pipeline(model= repo_path)
14
-
15
- model_2 = AutoModelForSequenceClassification.from_pretrained("runaksh/Symptom-2-disease_distilBERT")
16
- tokenizer_2 = AutoTokenizer.from_pretrained("runaksh/Symptom-2-disease_distilBERT")
17
-
18
- # Function for response generation
19
- def predict_sentiment(text):
20
- result = model_1(text)
21
- if result[0]['label'].endswith('0'):
22
- return 'Negative'
23
- else:
24
- return 'Positive'
25
-
26
- def predict(sample, validate=True):
27
- pred = classifier(sample)[0]['label']
28
- return pred
29
-
30
- def make_block(dem):
31
- with dem:
32
- gr.Markdown("Practicing for Capstone")
33
- with gr.Tabs():
34
- with gr.TabItem("Sentiment Classification"):
35
- with gr.Row():
36
- in_prompt_1 = gr.components.Textbox(lines=10, placeholder=None, label='Enter review text')
37
- out_response_1 = gr.components.Textbox(type="text", label='Sentiment')
38
- b1 = gr.Button("Enter")
39
-
40
- with gr.TabItem("Symptoms and Disease Classification"):
41
- with gr.Row():
42
- in_prompt_2 = gr.components.Textbox(lines=2, label='Enter the Symptoms')
43
- out_response_2 = gr.components.Textbox(label='Disease')
44
- b2 = gr.Button("Enter")
45
- b1.click(predict_sentiment, inputs=in_prompt_1, outputs=out_response_1)
46
- b2.click(predict, inputs=in_prompt_2, outputs=out_response_2)
47
-
48
- if __name__ == '__main__':
49
- model_1 = pipeline(model= repo_path)
50
- classifier = pipeline("text-classification", model=model_2, tokenizer=tokenizer_2)
51
-
52
- demo = gr.Blocks()
53
- make_block(demo)
54
- demo.launch()