Pisethan commited on
Commit
d98519f
·
verified ·
1 Parent(s): b407005

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -1,13 +1,20 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load model from Hugging Face Hub
 
 
 
 
 
5
  pipe = pipeline(
6
  "text-generation",
7
  model="Pisethan/khmer-lesson-model-v2",
8
- tokenizer="Pisethan/khmer-lesson-model"
 
9
  )
10
 
 
11
  # Define dropdown options
12
  grade_options = ["1", "2", "3", "4", "5", "6"]
13
  topic_options = ["Addition", "Subtraction", "Counting", "Number Recognition", "Multiplication", "Division"]
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+
5
+
6
+ import torch
7
+
8
+ device = 0 if torch.cuda.is_available() else -1
9
+
10
  pipe = pipeline(
11
  "text-generation",
12
  model="Pisethan/khmer-lesson-model-v2",
13
+ tokenizer="Pisethan/khmer-lesson-model",
14
+ device=device # 🔥 use GPU if available
15
  )
16
 
17
+
18
  # Define dropdown options
19
  grade_options = ["1", "2", "3", "4", "5", "6"]
20
  topic_options = ["Addition", "Subtraction", "Counting", "Number Recognition", "Multiplication", "Division"]