ruslanmv commited on
Commit
e4e6e3e
1 Parent(s): 8014203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -41
app.py CHANGED
@@ -7,11 +7,8 @@ IS_SPACES_ZERO = os.environ.get("SPACES_ZERO_GPU", "0") == "1"
7
  IS_SPACE = os.environ.get("SPACE_ID", None) is not None
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
10
- #device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
- #dtype = torch.float16
12
  LOW_MEMORY = os.getenv("LOW_MEMORY", "0") == "1"
13
  print(f"Using device: {device}")
14
- #print(f"Using dtype: {dtype}")
15
  print(f"low memory: {LOW_MEMORY}")
16
  model_name = "ruslanmv/Medical-Llama3-8B"
17
  # Move model and tokenizer to the CUDA device
@@ -35,8 +32,6 @@ def askme(symptoms, question):
35
  assistant_response =response_text.split("assistant")[1].strip().split("user")[0].strip()
36
  return assistant_response
37
 
38
-
39
-
40
  # Example usage
41
  symptoms = '''\
42
  I'm a 35-year-old male and for the past few months, I've been experiencing fatigue,
@@ -46,45 +41,9 @@ question = '''\
46
  Could these symptoms be related to hypothyroidism?
47
  If so, what steps should I take to get a proper diagnosis and discuss treatment options?
48
  '''
49
-
50
-
51
  examples = [
52
  [symptoms, question]
53
  ]
54
- '''
55
- iface = gr.Interface(
56
- fn=askme,
57
- inputs=["text", "text"],
58
- outputs="text",
59
- examples=examples,
60
- title="Medical AI Chatbot",
61
- description="Ask me a medical question!"
62
- )
63
-
64
- iface.launch()
65
- '''
66
-
67
- '''
68
-
69
- iface = gr.Interface(
70
- fn=askme,
71
- inputs=[
72
- gr.Textbox(label="Symptoms", placeholder="Enter symptoms here"),
73
- gr.Textbox(label="Question", placeholder="Enter question here")
74
- ],
75
- outputs="text",
76
- examples=examples,
77
- title="Medical AI Chatbot",
78
- description="Ask me a medical question!",
79
- css=css
80
- )
81
-
82
- iface.launch()
83
- '''
84
-
85
-
86
-
87
- import gradio as gr
88
 
89
  css = """
90
  /* General Container Styles */
@@ -147,3 +106,36 @@ with gr.Blocks(css=css) as interface:
147
 
148
  interface.launch()
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  IS_SPACE = os.environ.get("SPACE_ID", None) is not None
8
 
9
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
10
  LOW_MEMORY = os.getenv("LOW_MEMORY", "0") == "1"
11
  print(f"Using device: {device}")
 
12
  print(f"low memory: {LOW_MEMORY}")
13
  model_name = "ruslanmv/Medical-Llama3-8B"
14
  # Move model and tokenizer to the CUDA device
 
32
  assistant_response =response_text.split("assistant")[1].strip().split("user")[0].strip()
33
  return assistant_response
34
 
 
 
35
  # Example usage
36
  symptoms = '''\
37
  I'm a 35-year-old male and for the past few months, I've been experiencing fatigue,
 
41
  Could these symptoms be related to hypothyroidism?
42
  If so, what steps should I take to get a proper diagnosis and discuss treatment options?
43
  '''
 
 
44
  examples = [
45
  [symptoms, question]
46
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  css = """
49
  /* General Container Styles */
 
106
 
107
  interface.launch()
108
 
109
+
110
+
111
+
112
+ '''
113
+ iface = gr.Interface(
114
+ fn=askme,
115
+ inputs=["text", "text"],
116
+ outputs="text",
117
+ examples=examples,
118
+ title="Medical AI Chatbot",
119
+ description="Ask me a medical question!"
120
+ )
121
+
122
+ iface.launch()
123
+ '''
124
+
125
+ '''
126
+
127
+ iface = gr.Interface(
128
+ fn=askme,
129
+ inputs=[
130
+ gr.Textbox(label="Symptoms", placeholder="Enter symptoms here"),
131
+ gr.Textbox(label="Question", placeholder="Enter question here")
132
+ ],
133
+ outputs="text",
134
+ examples=examples,
135
+ title="Medical AI Chatbot",
136
+ description="Ask me a medical question!",
137
+ css=css
138
+ )
139
+
140
+ iface.launch()
141
+ '''