import threading from api import app import gradio as gr import torch import numpy as np from diffusers import DiffusionPipeline from transformers import pipeline def run_fastapi(): import uvicorn uvicorn.run(app, host="0.0.0.0", port=7860) # FastAPI را در یک رشته جداگانه اجرا کنید threading.Thread(target=run_fastapi).start() # ادامه کد Gradio همانطور که قبلا بوده # تعریف مثال example = [["sexy woman", True, 2, 398231747038484200, ""], # بقیه مثال‌ها ] with gr.Interface( fn=genie, inputs=[input_text, details_checkbox, steps_slider, seed_slider, cuda_checkbox], outputs=[output_image, output_text], title="Stable Diffusion Turbo with GPT", description="Type your text and lets create an image, check the box details if you want a creative picture", examples=example, ) as iface: iface.launch(inline=True, show_api=False, max_threads=200)