Spaces:
Runtime error
Runtime error
Update app.py
Browse files27 unmodified lines28293031323334353637383940413 unmodified lines4546474849505132 unmodified lines848586878889903 unmodified lines94959697989910027 unmodified lines# Define the Gradio interface@spaces.GPU()def single_condition_generate_image(prompt, subject_img, spatial_img, height, width, seed, control_type):# Set the control typeif control_type == "Ghibli":lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)# Process the imagesubject_imgs = [subject_img] if subject_img else []spatial_imgs = [spatial_img] if spatial_img else []image = pipe(prompt,3 unmodified linesnum_inference_steps=25,max_sequence_length=512,generator=torch.Generator("cpu").manual_seed(seed),subject_images=subject_imgs,spatial_images=spatial_imgs,cond_size=512,).images[0]32 unmodified lines# Add examples for Single Condition Generationgr.Examples(examples=single_examples,inputs=[prompt, None, spatial_img, height, width, seed, control_type],outputs=single_output_image,fn=single_condition_generate_image,cache_examples=False, # 缓存示例结果以加快加载速度3 unmodified lines# Link the buttons to the functionssingle_generate_btn.click(single_condition_generate_image,inputs=[prompt, None, spatial_img, height, width, seed, control_type],outputs=single_output_image)27 unmodified lines282930313233343536373839403 unmodified lines4445464748495032 unmodified lines838485868788893 unmodified lines9394959697989927 unmodified lines# Define the Gradio interface@spaces.GPU()def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type):# Set the control typeif control_type == "Ghibli":lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)# Process the imagespatial_imgs = [spatial_img] if spatial_img else []image = pipe(prompt,3 unmodified linesnum_inference_steps=25,max_sequence_length=512,generator=torch.Generator("cpu").manual_seed(seed),subject_images=[],spatial_images=spatial_imgs,cond_size=512,).images[0]32 unmodified lines# Add examples for Single Condition Generationgr.Examples(examples=single_examples,inputs=[prompt, spatial_img, height, width, seed, control_type],outputs=single_output_image,fn=single_condition_generate_image,cache_examples=False, # 缓存示例结果以加快加载速度3 unmodified lines# Link the buttons to the functionssingle_generate_btn.click(single_condition_generate_image,inputs=[prompt, spatial_img, height, width, seed, control_type],outputs=single_output_image)
app.py+4-5