gregorlied commited on
Commit
90e95e9
·
verified ·
1 Parent(s): 4f0bce5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -12,9 +12,10 @@ from pydantic import BaseModel
12
  hf_login(token=os.getenv("HF_TOKEN"))
13
 
14
  model_name = "meta-llama/Llama-3.2-1B-Instruct"
 
15
 
16
  model = AutoModelForCausalLM.from_pretrained(
17
- model_name, torch_dtype=torch.float32, device_map="auto"
18
  )
19
 
20
  class Person(BaseModel):
@@ -88,7 +89,7 @@ def summarize(text):
88
  {"role": "user", "content": text},
89
  ]
90
 
91
- model_inputs = tokenizer([text], return_tensors="pt").to('cuda')
92
 
93
  generated_ids = model.generate(
94
  input_ids=model_inputs["input_ids"],
@@ -119,13 +120,6 @@ with gr.Blocks() as demo:
119
  max_lines=15,
120
  placeholder="Paste your clinical report here...",
121
  )
122
- output_text = gr.Textbox(
123
- label="Summary",
124
- autoscroll=False,
125
- lines=15,
126
- max_lines=15,
127
- show_copy_button=True,
128
- )
129
 
130
  with gr.Row():
131
  summarize_btn = gr.Button("Summarize")
@@ -136,9 +130,18 @@ with gr.Blocks() as demo:
136
  show_progress=True,
137
  )
138
 
 
 
 
 
 
 
 
 
 
139
  with gr.Row():
140
  examples = gr.Examples(
141
- label="Example – Dialog",
142
  examples=[
143
  """A 48-year-old Indian woman was referred to the department of periodontology, with the chief complaint of swollen gums. She felt discomfort with the disfigurement of gums which appeared un esthetic due to its more severity and there was bleeding and difficulty while chewing food.
144
  Past medical history revealed that she is under medication for hypertension with amlodipine (10 mg/day orally) for the last 2 years and 6 months. The amlodipine dose was increased to 50 mg/day orally and statins were prescribed due to the acute angina attack and hypercholesterolemia before 6 months of the dental visit.
 
12
  hf_login(token=os.getenv("HF_TOKEN"))
13
 
14
  model_name = "meta-llama/Llama-3.2-1B-Instruct"
15
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
16
 
17
  model = AutoModelForCausalLM.from_pretrained(
18
+ model_name, torch_dtype=torch.float32, device_map=device
19
  )
20
 
21
  class Person(BaseModel):
 
89
  {"role": "user", "content": text},
90
  ]
91
 
92
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
93
 
94
  generated_ids = model.generate(
95
  input_ids=model_inputs["input_ids"],
 
120
  max_lines=15,
121
  placeholder="Paste your clinical report here...",
122
  )
 
 
 
 
 
 
 
123
 
124
  with gr.Row():
125
  summarize_btn = gr.Button("Summarize")
 
130
  show_progress=True,
131
  )
132
 
133
+ with gr.Row():
134
+ output_text = gr.Textbox(
135
+ label="Summary",
136
+ autoscroll=False,
137
+ lines=15,
138
+ max_lines=15,
139
+ show_copy_button=True,
140
+ )
141
+
142
  with gr.Row():
143
  examples = gr.Examples(
144
+ label="Examples",
145
  examples=[
146
  """A 48-year-old Indian woman was referred to the department of periodontology, with the chief complaint of swollen gums. She felt discomfort with the disfigurement of gums which appeared un esthetic due to its more severity and there was bleeding and difficulty while chewing food.
147
  Past medical history revealed that she is under medication for hypertension with amlodipine (10 mg/day orally) for the last 2 years and 6 months. The amlodipine dose was increased to 50 mg/day orally and statins were prescribed due to the acute angina attack and hypercholesterolemia before 6 months of the dental visit.