Remove broken Real-ESRGAN AI script and dependencies
This commit is contained in:
1 parent
adad32cafa
commit
a6d718e1a4
2 files changed
-67
No files matched your search
@@ -1,67 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
from PIL import Image, ImageEnhance, ImageOps
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
INPUT_DIR = os.path.join(BASE_DIR, 'media', 'Schnappix')
|
|
||||||
TMP_DIR = os.path.join(BASE_DIR, 'media', 'Schnappix_KI_Temp')
|
|
||||||
OUTPUT_DIR = os.path.join(BASE_DIR, 'media', 'Schnappix_KI_Fertig')
|
|
||||||
|
|
||||||
AI_EXECUTABLE = os.path.join(BASE_DIR, 'ai_enhancer', 'realesrgan-ncnn-vulkan.exe')
|
|
||||||
|
|
||||||
def process_images_with_ai():
|
|
||||||
if not os.path.exists(TMP_DIR):
|
|
||||||
os.makedirs(TMP_DIR)
|
|
||||||
if not os.path.exists(OUTPUT_DIR):
|
|
||||||
os.makedirs(OUTPUT_DIR)
|
|
||||||
print(f"Ordner erstellt: {OUTPUT_DIR}")
|
|
||||||
|
|
||||||
processed_count = 0
|
|
||||||
|
|
||||||
for filename in os.listdir(INPUT_DIR):
|
|
||||||
if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')):
|
|
||||||
input_path = os.path.join(INPUT_DIR, filename)
|
|
||||||
tmp_path = os.path.join(TMP_DIR, f"temp_{filename}")
|
|
||||||
output_path = os.path.join(OUTPUT_DIR, filename)
|
|
||||||
|
|
||||||
if os.path.exists(output_path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
print(f"\nVerarbeite {filename}...")
|
|
||||||
|
|
||||||
try:
|
|
||||||
# SCHRITT 1: KI-Entrauschung und Detail-Rekonstruktion
|
|
||||||
# -s 2 bedeutet: Auflösung verdoppeln (holt extrem viele Details zurück).
|
|
||||||
# -n realesrgan-x4plus ist das beste Modell für echte Fotos.
|
|
||||||
print(" -> KI entrauscht das Bild und rekonstruiert Details (das nutzt deine Grafikkarte)...")
|
|
||||||
# realesrgan verlangt oft png oder jpg als out, wir nutzen jpg
|
|
||||||
cmd = [AI_EXECUTABLE, '-i', input_path, '-o', tmp_path, '-s', '2', '-n', 'realesrgan-x4plus', '-f', 'jpg']
|
|
||||||
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
||||||
|
|
||||||
# SCHRITT 2: Farben und Kontrast anpassen (Dein Favoriten-Mix)
|
|
||||||
print(" -> Optimiere Farben und Kontrast...")
|
|
||||||
with Image.open(tmp_path) as img:
|
|
||||||
img_step1 = ImageOps.autocontrast(img, cutoff=1)
|
|
||||||
img_step2 = ImageEnhance.Brightness(img_step1).enhance(1.08)
|
|
||||||
img_final = ImageEnhance.Color(img_step2).enhance(1.2)
|
|
||||||
|
|
||||||
img_final.save(output_path, quality=95)
|
|
||||||
|
|
||||||
# Temp-Datei aufräumen
|
|
||||||
if os.path.exists(tmp_path):
|
|
||||||
os.remove(tmp_path)
|
|
||||||
|
|
||||||
print(f" -> Abgeschlossen!")
|
|
||||||
processed_count += 1
|
|
||||||
except Exception as e:
|
|
||||||
print(f" -> Fehler bei {filename}: {e}")
|
|
||||||
|
|
||||||
print(f"\nFertig! {processed_count} Bilder wurden durch die KI gejagt.")
|
|
||||||
print(f"Die fertigen Bilder liegen in: {OUTPUT_DIR}")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
if not os.path.exists(AI_EXECUTABLE):
|
|
||||||
print(f"KI-Tool nicht gefunden unter {AI_EXECUTABLE}. Bitte warten bis der Download abgeschlossen ist.")
|
|
||||||
else:
|
|
||||||
print("Starte KI-gestützte Bildbearbeitung (Real-ESRGAN + Color Boost)...")
|
|
||||||
process_images_with_ai()
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 MiB |
Reference in new issue
Block a user