Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files5 unmodified lines6789101139 unmodified lines51525354555624 unmodified lines8182838485868736 unmodified lines12412512612712812949 unmodified lines17918018118218318410 unmodified lines19519619719819920023 unmodified lines2242252262272282292305 unmodified linesfrom longcat_image.pipelines import LongCatImageEditPipelineimport numpy as npimport os# Global variables for modelpipe = None39 unmodified linesprint(f"❌ Error loading model: {e}")raisedef edit_image(input_image: Image.Image,prompt: str,24 unmodified linesprogress(0.2, desc="Generating edited image...")# Set random seed for reproducibilitygenerator = torch.Generator("cpu").manual_seed(seed)# Run the pipelinewith torch.inference_mode():36 unmodified lines<p style="font-size: 14px; margin-top: 10px;">Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #4A90E2; text-decoration: none;">anycoder</a></p></div>""")49 unmodified linesedit_btn = gr.Button("✨ Edit Image", variant="primary", size="lg")with gr.Column(scale=1):gr.Markdown("### 🎯 Output")output_image = gr.Image(10 unmodified lines- Supports both English and Chinese prompts- Try different guidance scales for varied results- Higher inference steps = better quality (but slower)""")# Examples section23 unmodified linesgr.HTML("""<div style="text-align: center; margin-top: 40px; padding: 20px; border-top: 1px solid #eee;"><p style="color: #666; font-size: 14px;">Powered by LongCat Image Edit |<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #4A90E2;">Built with anycoder</a></p></div>5 unmodified lines678910111239 unmodified lines5253545556575824 unmodified lines8384858687888936 unmodified lines12612712812913013113213313449 unmodified lines18418518618718818919019119219319419519619719810 unmodified lines20921021121221321421523 unmodified lines2392402412422432442455 unmodified linesfrom longcat_image.pipelines import LongCatImageEditPipelineimport numpy as npimport osimport spaces# Global variables for modelpipe = None39 unmodified linesprint(f"❌ Error loading model: {e}")raise@spaces.GPU(duration=120)def edit_image(input_image: Image.Image,prompt: str,24 unmodified linesprogress(0.2, desc="Generating edited image...")# Set random seed for reproducibilitygenerator = torch.Generator("cuda" if torch.cuda.is_available() else "cpu").manual_seed(seed)# Run the pipelinewith torch.inference_mode():36 unmodified lines<p style="font-size: 14px; margin-top: 10px;">Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #4A90E2; text-decoration: none;">anycoder</a></p><p style="font-size: 12px; color: #888; margin-top: 5px;">⚡ Powered by Zero-GPU</p></div>""")49 unmodified linesedit_btn = gr.Button("✨ Edit Image", variant="primary", size="lg")gr.Markdown("""<div style="padding: 10px; background-color: #f0f7ff; border-radius: 8px; margin-top: 10px;"><p style="margin: 0; font-size: 12px; color: #555;">⏱️ <strong>Note:</strong> Zero-GPU provides 120 seconds of GPU time per request.Processing typically takes 30-60 seconds depending on settings.</p></div>""")with gr.Column(scale=1):gr.Markdown("### 🎯 Output")output_image = gr.Image(10 unmodified lines- Supports both English and Chinese prompts- Try different guidance scales for varied results- Higher inference steps = better quality (but slower)- GPU time is limited - optimize your settings for speed""")# Examples section23 unmodified linesgr.HTML("""<div style="text-align: center; margin-top: 40px; padding: 20px; border-top: 1px solid #eee;"><p style="color: #666; font-size: 14px;">Powered by LongCat Image Edit with Zero-GPU |<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: #4A90E2;">Built with anycoder</a></p></div>
app.py+17-2