wie kann das ausgabefenster für das bild auf der rechten seite um 10 pixel höher gemacht…
- User
wie kann das ausgabefenster für das bild auf der rechten seite um 10 pixel höher gemacht werden. anbei der code: import os import gradio as gr import numpy as np import random from diffusers import DiffusionPipeline import torch from huggingface_hub import login from huggingface_hub.utils import RepositoryNotFoundError, GatedRepoError
Token aus Umgebungsvariable (z.B. HF_TOKEN) laden
token = os.getenv("HF_TOKEN")
device = "cuda" if torch.cuda.is_available() else "cpu" torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
MODEL_MAP = { "FLUX.1-schnell": "black-forest-labs/FLUX.1-schnell", "Stable Diffusion 1.5": "runwayml/stable-diffusion-v1-5", "DreamShaper v8": "Lykon/DreamShaper-v8", "Anything-v4": "andite/anything-v4", "Anything-v5": "andite/anything-v5", "OpenJourney v4": "prompthero/openjourney-v4", }
DEFAULT_POSITIVE = ( "photorealistic, ultra detailed, 8K resolution, cinematic lighting, natural colors, sharp focus, " "hyper-realistic, high-quality textures, intricate details, HDR, volumetric lighting, depth of field, " "realistic reflections, dynamic composition, professional photography, soft shadows, vivid colors, " "beautifully rendered, artistic masterpiece, lifelike portrayal" ) DEFAULT_NEGATIVE = ( "low quality, blurry, bad anatomy, extra limbs, watermark, text, distorted proportions, unnatural colors, " "heavy noise, pixelated, overexposed, inconsistent lighting, lack of detail, warped perspective, " "unrealistic expressions, compression artifacts, harsh shadows, cluttered composition, exaggerated features, " "unwanted text overlays, poor depth of field" )
pipe = None current_model = None
def load_model(model_name, enable_attention_slicing=True): global token model_repo_id = MODEL_MAP.get(model_name, MODEL_MAP["Stable Diffusion 1.5"])
codeprint(f"Lade Modell: {model_name} => {model_repo_id} auf {device} mit dtype={torch_dtype}") if token: print("Authentifiziere mit Hugging Face Token...") login(token) else: print("Kein HF-Token gefunden, nur öffentlich zugängliche Modelle verfügbar.") try: pipeline = DiffusionPipeline.from_pretrained( model_repo_id, torch_dtype=torch_dtype, ) pipeline = pipeline.to(device) if enable_attention_slicing: pipeline.enable_attention_slicing() return pipeline except (RepositoryNotFoundError, GatedRepoError) as e: print(f"Fehler beim Laden von {model_repo_id}: {e}") fallback_id = MODEL_MAP["Stable Diffusion 1.5"] print(f"Wechsel auf öffentliches Modell: {fallback_id}") pipeline = DiffusionPipeline.from_pretrained( fallback_id, torch_dtype=torch_dtype, ) pipeline = pipeline.to(device) if enable_attention_slicing: pipeline.enable_attention_slicing() return pipeline - Assistant