caesarCITREA commited on
Commit
e3bd131
·
1 Parent(s): e548c5b

Add application file

Browse files
Files changed (1) hide show
  1. app.py +57 -2
app.py CHANGED
@@ -1,4 +1,59 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
1
  import streamlit as st
2
+ import torch
3
+ from transformers import BertTokenizer, BertForSequenceClassification
4
+
5
+ # Load the tokenizer and model
6
+ tokenizer = BertTokenizer.from_pretrained('caesarCITREA/crocus-bert-medical-department-classification')
7
+ model = BertForSequenceClassification.from_pretrained('caesarCITREA/crocus-bert-medical-department-classification')
8
+
9
+ # Define the department names
10
+ departments = [
11
+ "Kadın Hastalıkları ve Doğum",
12
+ "Ortopedi ve Travmatoloji" ,
13
+ "Dermatoloji",
14
+ "Göğüs Hastalıkları ",
15
+ "Nöroloji",
16
+ "Onkoloji" ,
17
+ "Dahiliye (İç Hastalıkları)" ,
18
+ "Kardiyoloji",
19
+ "Psikiyatri" ,
20
+ "Pediatri" ,
21
+ "Nefroloji" ,
22
+ "Fiziksel Tıp ve Rehabilitasyon" ,
23
+ "Enfeksiyon Hastalıkları ve Klinik Mikrobiyoloji" ,
24
+ "Üroloji" ,
25
+ "Kulak Burun Boğaz (KBB)",
26
+ "Göz Hastalıkları"
27
+ ]
28
+
29
+ # Function to predict the department
30
+ def predict_department(description):
31
+ # Tokenize input
32
+ inputs = tokenizer(description, return_tensors="pt", truncation=True, padding=True)
33
+
34
+ # Perform inference
35
+ with torch.no_grad():
36
+ outputs = model(**inputs)
37
+ logits = outputs.logits
38
+
39
+ # Get the department with the highest score
40
+ predicted_class = torch.argmax(logits, dim=1).item()
41
+
42
+ # Return the department name
43
+ return departments[predicted_class]
44
+
45
+ # Streamlit app interface
46
+ st.title("Medical Department Classifier")
47
+
48
+ # Input text box for the user to describe the symptoms
49
+ description = st.text_area("Lütfen yaşadığınız tıbbi şikayetleri giriniz:")
50
+
51
+ # Button to classify the input
52
+ if st.button("Classify"):
53
+ if description:
54
+ department = predict_department(description)
55
+ st.write(f"Gitmeniz gereken tıbbi departman: **{department}**")
56
+ else:
57
+ st.write("Lütfen yaşadığınız durumu açıklanıyınız.")
58
+
59