Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
|
2 |
-
# Load model directly
|
3 |
-
from transformers import pipeline
|
4 |
-
import gradio as gr
|
5 |
-
import torch
|
6 |
-
|
7 |
-
# Check if CUDA is available, otherwise use CPU
|
8 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
9 |
-
|
10 |
-
pipe = pipeline("text-generation", model="microsoft/BioGPT-Large", device=device)
|
11 |
-
|
12 |
-
def question(message, history):
|
13 |
-
|
14 |
-
|
15 |
-
# Generate the response
|
16 |
-
response = pipe(message, max_length=200)[0]['generated_text']
|
17 |
-
|
18 |
-
return response
|
19 |
-
|
20 |
-
#Description in Markdown
|
21 |
-
description =
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
program = gr.ChatInterface(question,description=description,title="Microsoft BioGPT Large Chat")
|
26 |
-
|
27 |
-
if __name__ == "__main__":
|
28 |
program.launch()
|
|
|
1 |
+
|
2 |
+
# Load model directly
|
3 |
+
from transformers import pipeline
|
4 |
+
import gradio as gr
|
5 |
+
import torch
|
6 |
+
|
7 |
+
# Check if CUDA is available, otherwise use CPU
|
8 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
9 |
+
|
10 |
+
pipe = pipeline("text-generation", model="microsoft/BioGPT-Large", device=device)
|
11 |
+
|
12 |
+
def question(message, history):
|
13 |
+
|
14 |
+
|
15 |
+
# Generate the response
|
16 |
+
response = pipe(message, max_length=200)[0]['generated_text']
|
17 |
+
|
18 |
+
return response
|
19 |
+
|
20 |
+
#Description in Markdown
|
21 |
+
description =""
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
program = gr.ChatInterface(question,description=description,title="Microsoft BioGPT Large Chat")
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
program.launch()
|