import gradio as gr import requests from io import BytesIO from PIL import Image import os HARDCODED_URL = "" # Replace with your desired URL GLIF_API_TOKEN = os.getenv("GLIF_API_TOKEN") GLIF_API_URL = "https://simple-api.glif.app" glif_token_id = 0 glif_tokens_tried = 0 no_of_accounts = 11 def get_image_from_url(url): """ Loads and returns an image from a hardcoded URL. The prompt is ignored in this version. """ try: response = requests.get(url, stream=True) response.raise_for_status() image = Image.open(BytesIO(response.content)) return image except requests.exceptions.RequestException as e: return f"Error fetching image: {e}" except Exception as e: return f"Error processing image: {e}" def generate_image(prompt, aspect_ratio, realism): global glif_token_id global GLIF_API_TOKEN global glif_tokens_tried global no_of_accounts payload = { "id": "cm3ugmzv2002gnckiosrwk6xi", # Replace with appropriate ID if necessary "inputs": [prompt, aspect_ratio, str(realism).lower()], } headers = {"Authorization": f"Bearer {GLIF_API_TOKEN}"} try: # Make the POST request response_data = requests.post(GLIF_API_URL, json=payload, headers=headers).json() if "error" in response_data: if 'error 429' in response_data['error']: if glif_tokens_tried