Spaces:
Runtime error
Runtime error
Update app.py
Browse files11 unmodified lines121314151617181920212223242526272829303144 unmodified lines767778798011 unmodified linesdef load_models():global caption_image, sd_pipeline, translatorstart_time = time.time()# Load the image captioning modelcaption_image = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large", device=device)print(f"Caption model loaded in {time.time() - start_time:.2f} seconds")# Load the Stable Diffusion modelsd_pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to(device)print(f"Stable Diffusion model loaded in {time.time() - start_time:.2f} seconds")# Load the translation model (English to Arabic)translator = pipeline(task="translation",model="facebook/nllb-200-distilled-600M",torch_dtype=torch.bfloat16,device=device)print(f"Translator model loaded in {time.time() - start_time:.2f} seconds")44 unmodified lines# Launch the Gradio application within the main guardif __name__ == "__main__":interface.launch()11 unmodified lines1213141516171819202122232425262728293031323344 unmodified lines7879808111 unmodified linesdef load_models():global caption_image, sd_pipeline, translatorstart_time = time.time()# Load the image captioning modelcaption_image = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large", device=device)print(f"Caption model loaded in {time.time() - start_time:.2f} seconds")# Load the Stable Diffusion model with low CPU memory usagesd_pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",low_cpu_mem_usage=True # Enable low CPU memory usage).to(device)print(f"Stable Diffusion model loaded in {time.time() - start_time:.2f} seconds")# Load the translation modeltranslator = pipeline(task="translation",model="facebook/nllb-200-distilled-600M",device=device)print(f"Translator model loaded in {time.time() - start_time:.2f} seconds")44 unmodified lines# Launch the Gradio application within the main guardif __name__ == "__main__":interface.launch()
app.py+8-7