Spaces:
Build error
Build error
Commit ·
31c3ad2
1
Parent(s): 1290a3c
Update main.py
Browse files32 unmodified lines3334353637363738394037 unmodified lines787980818182838413 unmodified lines989910010110210310410510110210310410610710510910610710810932 unmodified lines input: str negativePrompt: str = '' steps: int = 25 cfg: int = 5 seed: int = 453666937 cfg: int = 7 seed: int = -1
#--------------------------------------------------- Generazione TESTO ------------------------------------------------------@app.post("/Genera")37 unmodified lines@app.post("/Immagine")def generate_image(request: Request, input_data: InputImage): client = Client("https://openskyml-fast-sdxl-stable-diffusion-xl.hf.space/--replicas/545b5tw7n/") max_attempts = 10 max_attempts = 20 attempt = 0 while attempt < max_attempts: try:13 unmodified lines img_base64 = base64.b64encode(img_binary).decode('utf-8') return {"response": img_base64} except requests.exceptions.HTTPError as e: if e.response.status_code == 500: time.sleep(1) attempt += 1 if attempt < max_attempts: continue time.sleep(1) attempt += 1 if attempt < max_attempts: continue else: return {"error": "Errore interno del server persistente"} else: return {"error": "Errore diverso da 500"} return {"error": "Errore interno del server persistente"} return {"error": "Numero massimo di tentativi raggiunto"}
@app.get("/")main.py+8-11