seyoungsong commited on
Commit
a2b29a7
1 Parent(s): ad640d9
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
3
 
@@ -130,11 +132,16 @@ lang_to_code = {
130
  lang_names = list(lang_to_code.keys())
131
 
132
  # load model
 
 
 
133
  tokenizer: M2M100Tokenizer = M2M100Tokenizer.from_pretrained(
134
- "seyoungsong/flores101_mm100_175M"
 
135
  )
136
  model = M2M100ForConditionalGeneration.from_pretrained(
137
- "seyoungsong/flores101_mm100_175M"
 
138
  )
139
 
140
  # fix tokenizer
 
1
+ from pathlib import Path
2
+
3
  import gradio as gr
4
  from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
5
 
 
132
  lang_names = list(lang_to_code.keys())
133
 
134
  # load model
135
+ cache_dir = Path("./cache_dir").resolve()
136
+ cache_dir.mkdir(exist_ok=True, parents=True)
137
+ print(f"cache_dir: {cache_dir}")
138
  tokenizer: M2M100Tokenizer = M2M100Tokenizer.from_pretrained(
139
+ pretrained_model_name_or_path="seyoungsong/flores101_mm100_175M",
140
+ cache_dir=str(cache_dir),
141
  )
142
  model = M2M100ForConditionalGeneration.from_pretrained(
143
+ pretrained_model_name_or_path="seyoungsong/flores101_mm100_175M",
144
+ cache_dir=str(cache_dir),
145
  )
146
 
147
  # fix tokenizer