jcrissa commited on
Commit
907eba6
·
1 Parent(s): 88fdb7b

edit app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,23 +1,24 @@
1
  import gradio as grad
2
  import torch
 
3
  from unsloth import FastLanguageModel
4
  from transformers import AutoTokenizer
5
 
6
  # Load your fine-tuned Phi-3 model from Hugging Face
7
  MODEL_NAME = "jcrissa/phi3-new-t2i"
8
 
9
- # Ensure that the device is correctly set (ZeroGPU or CPU)
10
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11
 
 
 
 
12
  def load_phi3_model():
13
  # Load the Phi-3 model and tokenizer from Hugging Face
14
  model, tokenizer = FastLanguageModel.from_pretrained(
15
  MODEL_NAME,
16
  max_seq_length=4096, # Ensure it matches your fine-tuning
17
- dtype=None # Use `torch.float16` if running on GPU
18
  )
19
 
20
- # Move the model to the appropriate device (ZeroGPU or CPU)
21
  model.to(device)
22
 
23
  # Configure tokenizer settings
 
1
  import gradio as grad
2
  import torch
3
+ import spaces
4
  from unsloth import FastLanguageModel
5
  from transformers import AutoTokenizer
6
 
7
  # Load your fine-tuned Phi-3 model from Hugging Face
8
  MODEL_NAME = "jcrissa/phi3-new-t2i"
9
 
 
 
10
 
11
+ device = "cuda"
12
+
13
+ @spaces.GPU
14
  def load_phi3_model():
15
  # Load the Phi-3 model and tokenizer from Hugging Face
16
  model, tokenizer = FastLanguageModel.from_pretrained(
17
  MODEL_NAME,
18
  max_seq_length=4096, # Ensure it matches your fine-tuning
19
+ dtype=torch.float16 # Use `torch.float16` if running on GPU
20
  )
21
 
 
22
  model.to(device)
23
 
24
  # Configure tokenizer settings