MAS-AI-0000 commited on
Commit
1a17328
·
verified ·
1 Parent(s): ebfa43c

Update imagePreprocess.py

Browse files
Files changed (1) hide show
  1. imagePreprocess.py +15 -4
imagePreprocess.py CHANGED
@@ -8,17 +8,28 @@ from tensorflow.keras.applications.resnet50 import preprocess_input
8
  import torch
9
  import clip
10
 
11
- BASE_DIR = "MAS-AI-0000/Authentica/tree/main"
12
  MODELS_DIR = os.path.join(BASE_DIR, "Lib/Models/Image")
13
 
 
 
 
 
 
 
 
 
 
 
 
14
  # Load models and preprocessing once at module level
15
  clip_mod, clip_pre = clip.load("ViT-B/32", jit=False)
16
  clip_mod.eval()
17
  for p in clip_mod.parameters():
18
  p.requires_grad = False
19
- mlp_model= tf.keras.models.load_model(os.path.join(MODELS_DIR, "clip_model.keras"))
20
- cnn_model = tf.keras.models.load_model(os.path.join(MODELS_DIR, "cnn_model.keras"))
21
- resnet_model = tf.keras.models.load_model(os.path.join(MODELS_DIR, "resnet_model.keras"))
22
 
23
 
24
  def center_crop(image: Image.Image, crop_size=512) -> Image.Image | str:
 
8
  import torch
9
  import clip
10
 
11
+ BASE_DIR = "MAS-AI-0000/Authentica"
12
  MODELS_DIR = os.path.join(BASE_DIR, "Lib/Models/Image")
13
 
14
+ # ==== CONFIG ====
15
+ REPO_ID = "MAS-AI-0000/Authentica"
16
+ CLIP_MODEL_FILENAME = "Lib/Models/Image/clip_model.keras"
17
+ CNN_MODEL_FILENAME = "Lib/Models/Image/cnn_model.keras"
18
+ RESNET_MODEL_FILENAME = "Lib/Models/Image/resnet_model.keras"
19
+
20
+ # ==== Load assets ====
21
+ clip_model_path = hf_hub_download(repo_id=REPO_ID, filename=CLIP_MODEL_FILENAME)
22
+ cnn_model_path = hf_hub_download(repo_id=REPO_ID, filename=CNN_MODEL_FILENAME)
23
+ resnet_model_path = hf_hub_download(repo_id=REPO_ID, filename=RESNET_MODEL_FILENAME)
24
+
25
  # Load models and preprocessing once at module level
26
  clip_mod, clip_pre = clip.load("ViT-B/32", jit=False)
27
  clip_mod.eval()
28
  for p in clip_mod.parameters():
29
  p.requires_grad = False
30
+ mlp_model= tf.keras.models.load_model(clip_model_path)
31
+ cnn_model = tf.keras.models.load_model(cnn_model_path)
32
+ resnet_model = tf.keras.models.load_model(resnet_model_path)
33
 
34
 
35
  def center_crop(image: Image.Image, crop_size=512) -> Image.Image | str: