yamildiego commited on
Commit
f5605e2
·
1 Parent(s): cb5a417

elon example

Browse files
Files changed (1) hide show
  1. handler.py +14 -11
handler.py CHANGED
@@ -82,11 +82,11 @@ class EndpointHandler():
82
  self.pipe.scheduler.config
83
  )
84
 
85
- scheduler_class_name = "EulerDiscreteScheduler"
86
-
87
- add_kwargs = {}
88
- scheduler = getattr(diffusers, scheduler_class_name)
89
- self.pipe.scheduler = scheduler.from_config(self.pipe.scheduler.config, **add_kwargs)
90
 
91
  controlnet_pose_model = "thibaud/controlnet-openpose-sdxl-1.0"
92
  controlnet_canny_model = "diffusers/controlnet-canny-sdxl-1.0"
@@ -98,6 +98,7 @@ class EndpointHandler():
98
  controlnet_canny = ControlNetModel.from_pretrained(
99
  controlnet_canny_model, torch_dtype=dtype
100
  ).to(device)
 
101
  # controlnet_depth = ControlNetModel.from_pretrained(
102
  # controlnet_depth_model, torch_dtype=dtype
103
  # ).to(device)
@@ -144,8 +145,9 @@ class EndpointHandler():
144
  }
145
 
146
  self.app = FaceAnalysis(name="buffalo_l", root="./", providers=["CPUExecutionProvider"])
147
- self.app.prepare(ctx_id=0, det_size=(512, 512))
148
- self.generator = torch.Generator(device=device.type).manual_seed(3)
 
149
 
150
 
151
  identitynet_strength_ratio = 0.8
@@ -170,13 +172,14 @@ class EndpointHandler():
170
  ]
171
 
172
  def __call__(self, data):
173
-
174
- default_prompt = "watercolor painting, {prompt}. vibrant, beautiful, painterly, detailed, textural, artistic"
 
175
  default_negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
176
 
177
  # hyperparamters
178
  # prompt_input = data.pop("inputs", "a man")
179
- prompt_input = "a man"
180
  prompt=default_prompt.replace("{prompt}", prompt_input)
181
  num_inference_steps = data.pop("num_inference_steps", 20)
182
  guidance_scale = data.pop("guidance_scale", 5.0)
@@ -191,7 +194,7 @@ class EndpointHandler():
191
 
192
  # original
193
  face_image_path = "https://i.ibb.co/GQzm527/examples-musk-resize.jpg"
194
- pose_image_path = "https://i.ibb.co/ZSrQ8ZJ/pose.jpg"
195
 
196
  adapter_strength_ratio = 0.8
197
 
 
82
  self.pipe.scheduler.config
83
  )
84
 
85
+ # if we need more parameters
86
+ # scheduler_class_name = "EulerDiscreteScheduler"
87
+ # add_kwargs = {}
88
+ # scheduler = getattr(diffusers, scheduler_class_name)
89
+ # self.pipe.scheduler = scheduler.from_config(self.pipe.scheduler.config, **add_kwargs)
90
 
91
  controlnet_pose_model = "thibaud/controlnet-openpose-sdxl-1.0"
92
  controlnet_canny_model = "diffusers/controlnet-canny-sdxl-1.0"
 
98
  controlnet_canny = ControlNetModel.from_pretrained(
99
  controlnet_canny_model, torch_dtype=dtype
100
  ).to(device)
101
+
102
  # controlnet_depth = ControlNetModel.from_pretrained(
103
  # controlnet_depth_model, torch_dtype=dtype
104
  # ).to(device)
 
145
  }
146
 
147
  self.app = FaceAnalysis(name="buffalo_l", root="./", providers=["CPUExecutionProvider"])
148
+ # con 512 funciona bien
149
+ self.app.prepare(ctx_id=0, det_size=(640, 640))
150
+ self.generator = torch.Generator(device=device).manual_seed(42)
151
 
152
 
153
  identitynet_strength_ratio = 0.8
 
172
  ]
173
 
174
  def __call__(self, data):
175
+
176
+ default_prompt = "{prompt}, Post-apocalyptic. Mars Colony, Scavengers roam the wastelands searching for valuable resources, rovers, bright morning sunlight shining, (detailed) (intricate) (8k) (HDR) (cinematic lighting) (sharp focus)"
177
+ # default_prompt = "watercolor painting, {prompt}. vibrant, beautiful, painterly, detailed, textural, artistic"
178
  default_negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
179
 
180
  # hyperparamters
181
  # prompt_input = data.pop("inputs", "a man")
182
+ prompt_input = "a man flying in the sky in Mars"
183
  prompt=default_prompt.replace("{prompt}", prompt_input)
184
  num_inference_steps = data.pop("num_inference_steps", 20)
185
  guidance_scale = data.pop("guidance_scale", 5.0)
 
194
 
195
  # original
196
  face_image_path = "https://i.ibb.co/GQzm527/examples-musk-resize.jpg"
197
+ pose_image_path = "https://i.ibb.co/TRCK4MS/examples-poses-pose2.jpg"
198
 
199
  adapter_strength_ratio = 0.8
200