Ruian7P commited on
Commit
2bdefe0
·
1 Parent(s): 07e2f24

should work this time

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -25,19 +25,19 @@ ensure_env_installed()
25
 
26
  # Global model variable
27
  model_zoo = {
28
- "imuru_t5_small": {
29
- "repo_id": "Ruian7P/emuru_result",
30
- "model_name": "imuru_t5_small_2e-5_ech5"
31
  },
32
- "emuru_t5_small": {
33
- "repo_id": "Ruian7P/emuru_result",
34
- "model_name": "emuru_t5_small_2e-5_ech5"
35
- }
36
  }
37
 
38
  model = None
39
 
40
- def load_model(model_name="imuru_t5_small"):
41
  global model
42
 
43
  if model is None:
@@ -45,7 +45,8 @@ def load_model(model_name="imuru_t5_small"):
45
  from transformers import AutoModel
46
 
47
  model = AutoModel.from_pretrained(
48
- f"{model_zoo[model_name]['repo_id']}/{model_zoo[model_name]['model_name']}",
 
49
  trust_remote_code=True
50
  )
51
  model.eval()
@@ -72,7 +73,7 @@ def process_image(img):
72
 
73
 
74
  @spaces.GPU
75
- def generate_handwriting(style_image, gen_text, model_name="imuru_t5_small"):
76
  """Generate handwriting in the style of the input image."""
77
  if not gen_text or gen_text.strip() == "":
78
  return None, "❌ Please provide text to generate"
@@ -143,7 +144,7 @@ with gr.Blocks(css=custom_css, title="Imuru") as demo:
143
  model_selector = gr.Dropdown(
144
  label="🤖 Select Model",
145
  choices=list(model_zoo.keys()),
146
- value="imuru_t5_small",
147
  interactive=True
148
  )
149
 
 
25
 
26
  # Global model variable
27
  model_zoo = {
28
+ "imuru_small": {
29
+ "repo_id": "Ruian7P/imuru_small",
30
+ "model_name": None
31
  },
32
+ # "emuru_t5_small": {
33
+ # "repo_id": "Ruian7P/emuru_result",
34
+ # "model_name": "emuru_t5_small_2e-5_ech5"
35
+ # }
36
  }
37
 
38
  model = None
39
 
40
+ def load_model(model_name="imuru_small"):
41
  global model
42
 
43
  if model is None:
 
45
  from transformers import AutoModel
46
 
47
  model = AutoModel.from_pretrained(
48
+ model_zoo[model_name]["repo_id"],
49
+ subfolder=model_zoo[model_name]["model_name"],
50
  trust_remote_code=True
51
  )
52
  model.eval()
 
73
 
74
 
75
  @spaces.GPU
76
+ def generate_handwriting(style_image, gen_text, model_name="imuru_small"):
77
  """Generate handwriting in the style of the input image."""
78
  if not gen_text or gen_text.strip() == "":
79
  return None, "❌ Please provide text to generate"
 
144
  model_selector = gr.Dropdown(
145
  label="🤖 Select Model",
146
  choices=list(model_zoo.keys()),
147
+ value="imuru_small",
148
  interactive=True
149
  )
150