Spaces:
Sleeping
Sleeping
Commit ·
31c3ad2
1
Parent(s): 1290a3c
Update main.py
Browse files32 unmodified lines333435363738394037 unmodified lines7879808182838413 unmodified lines989910010110210310410510610710810911011111232 unmodified linesinput: strnegativePrompt: str = ''steps: int = 25cfg: int = 5seed: int = 453666937#--------------------------------------------------- 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 = 10attempt = 0while attempt < max_attempts:try:13 unmodified linesimg_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 += 1if attempt < max_attempts:continueelse:return {"error": "Errore interno del server persistente"}else:return {"error": "Errore diverso da 500"}return {"error": "Numero massimo di tentativi raggiunto"}@app.get("/")32 unmodified lines333435363738394037 unmodified lines7879808182838413 unmodified lines989910010110210310410510610710810932 unmodified linesinput: strnegativePrompt: str = ''steps: int = 25cfg: int = 7seed: 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 = 20attempt = 0while attempt < max_attempts:try:13 unmodified linesimg_base64 = base64.b64encode(img_binary).decode('utf-8')return {"response": img_base64}except requests.exceptions.HTTPError as e:time.sleep(1)attempt += 1if attempt < max_attempts:continueelse:return {"error": "Errore interno del server persistente"}return {"error": "Numero massimo di tentativi raggiunto"}@app.get("/")
main.py+8-11