runaksh commited on
Commit
cfbd2d8
·
1 Parent(s): bc494d5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """gradio_deploy.ipynb
3
+ Automatically generated by Colaboratory.
4
+ """
5
+ import os
6
+ import gradio
7
+ from PIL import Image
8
+ from timeit import default_timer as timer
9
+ from tensorflow import keras
10
+ import torch
11
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
12
+ import numpy as np
13
+
14
+ loaded_model = AutoModelWithLMHead.from_pretrained("runaksh/Symptom-2-disease_distilBERT")
15
+ loaded_tokenizer = AutoTokenizer.from_pretrained("runaksh/Symptom-2-disease_distilBERT")
16
+
17
+ # Function for class prediction
18
+ def predict(sample, validate=True):
19
+ classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
20
+ pred = classifier(sample)[0]['label']
21
+ return pred
22
+
23
+ title = "Symptoms and Disease"
24
+ description = "Enter the Symptoms to know the associated disease"
25
+
26
+ # Gradio elements
27
+
28
+ # Input from user
29
+ in_prompt = gradio.inputs.Textbox(lines=2, label='Enter the Symptoms')
30
+
31
+ # Output response
32
+ out_response = gradio.outputs.Textbox(label='Disease')
33
+
34
+ # Gradio interface to generate UI link
35
+ iface = gradio.Interface(fn=predict,
36
+ inputs = in_prompt,
37
+ outputs = out_response
38
+ )
39
+
40
+ iface.launch(debug = True)