kadirnar commited on
Commit
cac6536
1 Parent(s): 7eadeda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -6,6 +6,27 @@ import shutil
6
  import os
7
  import spaces
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def download_model(repo_id, model_name):
10
  model_path = hf_hub_download(repo_id=repo_id, filename=model_name)
11
  return model_path
 
6
  import os
7
  import spaces
8
 
9
+ from transformers import T5ForConditionalGeneration, T5Tokenizer
10
+ import os
11
+
12
+ def download_t5_model(model_id, save_directory):
13
+ # Modelin tokenizer'ını ve modeli indir
14
+ model = T5ForConditionalGeneration.from_pretrained(model_id)
15
+ tokenizer = T5Tokenizer.from_pretrained(model_id)
16
+
17
+ # Model ve tokenizer'ı belirtilen dizine kaydet
18
+ if not os.path.exists(save_directory):
19
+ os.makedirs(save_directory)
20
+ model.save_pretrained(save_directory)
21
+ tokenizer.save_pretrained(save_directory)
22
+
23
+ # Model ID ve kaydedilecek dizin
24
+ model_id = "DeepFloyd/t5-v1_1-xxl"
25
+ save_directory = "pretrained_models/t5_ckpts/t5-v1_1-xxl"
26
+
27
+ # Modeli indir
28
+ download_t5_model(model_id, save_directory)
29
+
30
  def download_model(repo_id, model_name):
31
  model_path = hf_hub_download(repo_id=repo_id, filename=model_name)
32
  return model_path