vhup 1.3__tar.gz → 1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vhup-1.3/vhup.egg-info → vhup-1.4}/PKG-INFO +1 -1
- {vhup-1.3 → vhup-1.4}/setup.py +1 -1
- vhup-1.4/vhup/__init__.py +1 -0
- {vhup-1.3 → vhup-1.4/vhup.egg-info}/PKG-INFO +1 -1
- {vhup-1.3 → vhup-1.4}/vhup.egg-info/SOURCES.txt +0 -1
- vhup-1.3/vhup/__init__.py +0 -2
- vhup-1.3/vhup/horba.py +0 -83
- {vhup-1.3 → vhup-1.4}/LICENSE +0 -0
- {vhup-1.3 → vhup-1.4}/README.md +0 -0
- {vhup-1.3 → vhup-1.4}/setup.cfg +0 -0
- {vhup-1.3 → vhup-1.4}/vhup/vhup.py +0 -0
- {vhup-1.3 → vhup-1.4}/vhup.egg-info/dependency_links.txt +0 -0
- {vhup-1.3 → vhup-1.4}/vhup.egg-info/requires.txt +0 -0
- {vhup-1.3 → vhup-1.4}/vhup.egg-info/top_level.txt +0 -0
{vhup-1.3 → vhup-1.4}/setup.py
RENAMED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .vhup import create_text
|
vhup-1.3/vhup/__init__.py
DELETED
vhup-1.3/vhup/horba.py
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import torch
|
|
2
|
-
import cv2
|
|
3
|
-
import numpy as np
|
|
4
|
-
import os
|
|
5
|
-
from PIL import Image
|
|
6
|
-
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, DPMSolverMultistepScheduler
|
|
7
|
-
from deep_translator import GoogleTranslator
|
|
8
|
-
from gfpgan import GFPGANer # Yüz düzelticiyi ekledik
|
|
9
|
-
|
|
10
|
-
# Donanım ayarları
|
|
11
|
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
12
|
-
dtype = torch.float16 if device == "cuda" else torch.float32
|
|
13
|
-
|
|
14
|
-
# 1. Yüz Düzelticiyi Başlat (Kodu bozmaz, sadece üretim sonrası devreye girer)
|
|
15
|
-
face_enhancer = GFPGANer(
|
|
16
|
-
model_path='https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth',
|
|
17
|
-
upscale=1,
|
|
18
|
-
arch='clean',
|
|
19
|
-
channel_multiplier=2,
|
|
20
|
-
device=device
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
# 2. ControlNet ve Model Yükleme
|
|
24
|
-
controlnet = ControlNetModel.from_pretrained(
|
|
25
|
-
"lllyasviel/sd-controlnet-canny",
|
|
26
|
-
torch_dtype=dtype
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
_pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
|
30
|
-
"runwayml/stable-diffusion-v1-5",
|
|
31
|
-
controlnet=controlnet,
|
|
32
|
-
torch_dtype=dtype,
|
|
33
|
-
safety_checker=None
|
|
34
|
-
).to(device)
|
|
35
|
-
|
|
36
|
-
_pipe.scheduler = DPMSolverMultistepScheduler.from_config(_pipe.scheduler.config)
|
|
37
|
-
translator = GoogleTranslator(source="tr", target="en")
|
|
38
|
-
|
|
39
|
-
def create_loop(prompt: str, foto: str) -> str:
|
|
40
|
-
# A. Referans Görsel İşleme
|
|
41
|
-
input_image = Image.open(foto).convert("RGB")
|
|
42
|
-
image_np = np.array(input_image)
|
|
43
|
-
|
|
44
|
-
image_canny = cv2.Canny(image_np, 100, 200)
|
|
45
|
-
image_canny = image_canny[:, :, None]
|
|
46
|
-
image_canny = np.concatenate([image_canny, image_canny, image_canny], axis=2)
|
|
47
|
-
canny_image = Image.fromarray(image_canny)
|
|
48
|
-
|
|
49
|
-
# B. Prompt Hazırlığı
|
|
50
|
-
translated_prompt = translator.translate(prompt)
|
|
51
|
-
final_prompt = f"{translated_prompt}, highly detailed, masterpiece, 8k wallpaper"
|
|
52
|
-
negative_prompt = "lowres, bad anatomy, worst quality, blurry, deformed face"
|
|
53
|
-
|
|
54
|
-
# C. Üretim Süreci
|
|
55
|
-
output_raw = _pipe(
|
|
56
|
-
prompt=final_prompt,
|
|
57
|
-
image=canny_image,
|
|
58
|
-
negative_prompt=negative_prompt,
|
|
59
|
-
num_inference_steps=30,
|
|
60
|
-
controlnet_conditioning_scale=0.7
|
|
61
|
-
).images[0]
|
|
62
|
-
|
|
63
|
-
# --- YÜZ DÜZELTME (Sistemi bozmadan eklenen katman) ---
|
|
64
|
-
# PIL görselini OpenCV formatına çevir
|
|
65
|
-
open_cv_image = cv2.cvtColor(np.array(output_raw), cv2.COLOR_RGB2BGR)
|
|
66
|
-
|
|
67
|
-
# GFPGAN ile yüzü işle
|
|
68
|
-
_, _, restored_img = face_enhancer.enhance(
|
|
69
|
-
open_cv_image,
|
|
70
|
-
has_aligned=False,
|
|
71
|
-
only_center_face=False,
|
|
72
|
-
paste_back=True
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
# Sonucu tekrar PIL formatına döndür
|
|
76
|
-
final_image = Image.fromarray(cv2.cvtColor(restored_img, cv2.COLOR_BGR2RGB))
|
|
77
|
-
# ---------------------------------------------------
|
|
78
|
-
|
|
79
|
-
# D. Kayıt
|
|
80
|
-
output_path = "vho_result.png"
|
|
81
|
-
final_image.save(output_path)
|
|
82
|
-
return os.path.abspath(output_path)
|
|
83
|
-
|
{vhup-1.3 → vhup-1.4}/LICENSE
RENAMED
|
File without changes
|
{vhup-1.3 → vhup-1.4}/README.md
RENAMED
|
File without changes
|
{vhup-1.3 → vhup-1.4}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|