model2 commited on
Commit
2941d7e
·
1 Parent(s): ce308f8

image sizing

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -20,7 +20,6 @@ import yaml
20
  from huggingface_hub import hf_hub_download
21
 
22
  import folder_paths
23
- from comfy import model_management
24
  from nodes import NODE_CLASS_MAPPINGS
25
 
26
  # Load available models from HF
@@ -54,11 +53,6 @@ hf_hub_download(
54
  filename="buffalo_l.zip",
55
  local_dir="models/insightface/models",
56
  )
57
- # hf_hub_download(
58
- # repo_id="AdamCodd/vit-base-nsfw-detector",
59
- # filename="model.safetensors",
60
- # local_dir="models/nsfw_detector/vit-base-nsfw-detector",
61
- # )
62
  hf_hub_download(
63
  repo_id="model2/advance_face_model",
64
  filename="advance_face_model.safetensors",
@@ -96,6 +90,7 @@ def import_custom_nodes() -> None:
96
  # Preload nodes, models.
97
  import_custom_nodes()
98
  loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
 
99
  upscalemodelloader = NODE_CLASS_MAPPINGS["UpscaleModelLoader"]()
100
  reactorloadfacemodel = NODE_CLASS_MAPPINGS["ReActorLoadFaceModel"]()
101
  FACE_MODEL = reactorloadfacemodel.load_model(
@@ -106,13 +101,6 @@ reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
106
  imageupscalewithmodel = NODE_CLASS_MAPPINGS["ImageUpscaleWithModel"]()
107
  saveimage = NODE_CLASS_MAPPINGS["SaveImage"]()
108
  UPSCALE_MODEL = upscalemodelloader.load_model(model_name="ESRGAN/4x_NMKD-Siax_200k.pth")
109
- # model_loaders = [
110
- # UPSCALE_MODEL,
111
- # FACE_MODEL,
112
- # ]
113
- # model_management.load_models_gpu([
114
- # loader[0].patcher if hasattr(loader[0], 'patcher') else loader[0] for loader in model_loaders
115
- # ])
116
 
117
 
118
  def load_extra_path_config(yaml_path):
@@ -230,6 +218,12 @@ def advance_blur(input_image):
230
  image=input_image,
231
  )
232
 
 
 
 
 
 
 
233
  resized_input_image = imageresize.execute(
234
  width=2560,
235
  height=2560,
@@ -262,8 +256,8 @@ def advance_blur(input_image):
262
  )
263
 
264
  final_image = imageresize.execute(
265
- width=2560,
266
- height=2560,
267
  interpolation="lanczos",
268
  method="keep proportion",
269
  condition="downscale if bigger",
 
20
  from huggingface_hub import hf_hub_download
21
 
22
  import folder_paths
 
23
  from nodes import NODE_CLASS_MAPPINGS
24
 
25
  # Load available models from HF
 
53
  filename="buffalo_l.zip",
54
  local_dir="models/insightface/models",
55
  )
 
 
 
 
 
56
  hf_hub_download(
57
  repo_id="model2/advance_face_model",
58
  filename="advance_face_model.safetensors",
 
90
  # Preload nodes, models.
91
  import_custom_nodes()
92
  loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
93
+ getimagesize = NODE_CLASS_MAPPINGS["GetImageSize"]()
94
  upscalemodelloader = NODE_CLASS_MAPPINGS["UpscaleModelLoader"]()
95
  reactorloadfacemodel = NODE_CLASS_MAPPINGS["ReActorLoadFaceModel"]()
96
  FACE_MODEL = reactorloadfacemodel.load_model(
 
101
  imageupscalewithmodel = NODE_CLASS_MAPPINGS["ImageUpscaleWithModel"]()
102
  saveimage = NODE_CLASS_MAPPINGS["SaveImage"]()
103
  UPSCALE_MODEL = upscalemodelloader.load_model(model_name="ESRGAN/4x_NMKD-Siax_200k.pth")
 
 
 
 
 
 
 
104
 
105
 
106
  def load_extra_path_config(yaml_path):
 
218
  image=input_image,
219
  )
220
 
221
+ image_size = getimagesize.execute(
222
+ image=get_value_at_index(loaded_input_image, 0),
223
+ )
224
+ original_width = get_value_at_index(image_size, 0)
225
+ original_height = get_value_at_index(image_size, 1)
226
+
227
  resized_input_image = imageresize.execute(
228
  width=2560,
229
  height=2560,
 
256
  )
257
 
258
  final_image = imageresize.execute(
259
+ width=original_width,
260
+ height=original_height,
261
  interpolation="lanczos",
262
  method="keep proportion",
263
  condition="downscale if bigger",