add qwen image edit
Browse files1226 unmodified lines122712281229123012311232123336 unmodified lines1270127112721273127412751276127712781279128012811282128312843539 unmodified lines48244825482648274828482948301226 unmodified linesreturn f"Error generating image: {str(e)}"def generate_image_to_image(input_image_data, prompt: str) -> str:"""Generate an image using image-to-image with FLUX.1-Kontext-dev via Hugging Face InferenceClient.Returns an HTML <img> tag with optimized base64 JPEG data, similar to text-to-image output."""36 unmodified linesif pil_image.mode != 'RGB':pil_image = pil_image.convert('RGB')buf = io.BytesIO()pil_image.save(buf, format='PNG')input_bytes = buf.getvalue()# Call image-to-imageimage = client.image_to_image(input_bytes,prompt=prompt,model="black-forest-labs/FLUX.1-Kontext-dev",)# Resize/optimize3539 unmodified lineslabel="🖼️ Image to Image (uses input image)",value=False,visible=True,info="Transform your uploaded image using FLUX.1-Kontext-dev")image_to_video_toggle = gr.Checkbox(label="🎞️ Image to Video (uses input image)",1226 unmodified lines122712281229123012311232123336 unmodified lines127012711272127312741275127612771278127912801281128212831284128512861287128812893539 unmodified lines48294830483148324833483448351226 unmodified linesreturn f"Error generating image: {str(e)}"def generate_image_to_image(input_image_data, prompt: str) -> str:"""Generate an image using image-to-image with Qwen-Image-Edit via Hugging Face InferenceClient.Returns an HTML <img> tag with optimized base64 JPEG data, similar to text-to-image output."""36 unmodified linesif pil_image.mode != 'RGB':pil_image = pil_image.convert('RGB')# Resize input image to avoid request body size limitsmax_input_size = 1024if pil_image.width > max_input_size or pil_image.height > max_input_size:pil_image.thumbnail((max_input_size, max_input_size), Image.Resampling.LANCZOS)buf = io.BytesIO()pil_image.save(buf, format='JPEG', quality=85, optimize=True)input_bytes = buf.getvalue()# Call image-to-imageimage = client.image_to_image(input_bytes,prompt=prompt,model="Qwen/Qwen-Image-Edit",)# Resize/optimize3539 unmodified lineslabel="🖼️ Image to Image (uses input image)",value=False,visible=True,info="Transform your uploaded image using Qwen-Image-Edit")image_to_video_toggle = gr.Checkbox(label="🎞️ Image to Video (uses input image)",
app.py+9-4