Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
)
|
| 15 |
|
| 16 |
# β
Dropdown choices
|
| 17 |
grade_options = ["1", "2", "3", "4", "5", "6"]
|
|
@@ -74,3 +74,5 @@ with gr.Blocks() as demo:
|
|
| 74 |
|
| 75 |
# β
Launch app with public link
|
| 76 |
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
| 1 |
+
from spaces import GPU
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
+
@GPU # π REQUIRED to activate GPU on Hugging Face ZeroGPU
|
| 7 |
+
def main():
|
| 8 |
+
device = 0 if torch.cuda.is_available() else -1
|
| 9 |
+
pipe = pipeline(
|
| 10 |
+
"text-generation",
|
| 11 |
+
model="Pisethan/khmer-lesson-model-v2",
|
| 12 |
+
tokenizer="Pisethan/khmer-lesson-model",
|
| 13 |
+
device=device
|
| 14 |
+
)
|
|
|
|
| 15 |
|
| 16 |
# β
Dropdown choices
|
| 17 |
grade_options = ["1", "2", "3", "4", "5", "6"]
|
|
|
|
| 74 |
|
| 75 |
# β
Launch app with public link
|
| 76 |
demo.launch(share=True)
|
| 77 |
+
|
| 78 |
+
main()
|