vhup 0.2__tar.gz → 0.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-0.2 → vhup-0.4}/PKG-INFO +4 -1
- {vhup-0.2 → vhup-0.4}/setup.py +5 -2
- vhup-0.4/vhup/__init__.py +2 -0
- vhup-0.4/vhup/horba.py +110 -0
- {vhup-0.2 → vhup-0.4}/vhup.egg-info/PKG-INFO +4 -1
- {vhup-0.2 → vhup-0.4}/vhup.egg-info/SOURCES.txt +2 -1
- {vhup-0.2 → vhup-0.4}/vhup.egg-info/requires.txt +3 -0
- vhup-0.2/vhup/__init__.py +0 -1
- {vhup-0.2 → vhup-0.4}/LICENSE +0 -0
- {vhup-0.2 → vhup-0.4}/README.md +0 -0
- {vhup-0.2 → vhup-0.4}/setup.cfg +0 -0
- /vhup-0.2/vhup/vhub.py → /vhup-0.4/vhup/vhup.py +0 -0
- {vhup-0.2 → vhup-0.4}/vhup.egg-info/dependency_links.txt +0 -0
- {vhup-0.2 → vhup-0.4}/vhup.egg-info/top_level.txt +0 -0
{vhup-0.2 → vhup-0.4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vhup
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4
|
|
4
4
|
Summary: Vho: İşlevsel ve kolaylaştırılmış görsel oluşturma kütüphanesi
|
|
5
5
|
Author: Bedirhan
|
|
6
6
|
Author-email: bedirhan.oytpass@gmail.com
|
|
@@ -31,6 +31,9 @@ Requires-Dist: face_recognition
|
|
|
31
31
|
Requires-Dist: Pillow
|
|
32
32
|
Requires-Dist: insightface>=0.7.3
|
|
33
33
|
Requires-Dist: onnxruntime-gpu
|
|
34
|
+
Requires-Dist: peft
|
|
35
|
+
Requires-Dist: sentencepiece
|
|
36
|
+
Requires-Dist: protobuf
|
|
34
37
|
Dynamic: author
|
|
35
38
|
Dynamic: author-email
|
|
36
39
|
Dynamic: classifier
|
{vhup-0.2 → vhup-0.4}/setup.py
RENAMED
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="vhup",
|
|
8
|
-
version="0.
|
|
8
|
+
version="0.4",
|
|
9
9
|
packages=find_packages(),
|
|
10
10
|
install_requires=[
|
|
11
11
|
"torch>=2.0.0",
|
|
@@ -23,7 +23,10 @@ setup(
|
|
|
23
23
|
"face_recognition",
|
|
24
24
|
"Pillow",
|
|
25
25
|
"insightface>=0.7.3",
|
|
26
|
-
"onnxruntime-gpu"
|
|
26
|
+
"onnxruntime-gpu",
|
|
27
|
+
"peft",
|
|
28
|
+
"sentencepiece",
|
|
29
|
+
"protobuf"
|
|
27
30
|
],
|
|
28
31
|
description="Vho: İşlevsel ve kolaylaştırılmış görsel oluşturma kütüphanesi",
|
|
29
32
|
long_description=README,
|
vhup-0.4/vhup/horba.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import random
|
|
3
|
+
import os
|
|
4
|
+
from PIL import Image
|
|
5
|
+
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
|
|
6
|
+
from deep_translator import GoogleTranslator
|
|
7
|
+
|
|
8
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
9
|
+
dtype = torch.float16 if device == "cuda" else torch.float32
|
|
10
|
+
|
|
11
|
+
FIXED_OUTPUT_FILE = "vho1.png"
|
|
12
|
+
|
|
13
|
+
translator = GoogleTranslator(source="tr", target="en")
|
|
14
|
+
|
|
15
|
+
TR_STYLE_MAP = {
|
|
16
|
+
"gerçekçi": "realistic",
|
|
17
|
+
"sinematik": "cinematic lighting",
|
|
18
|
+
"anime": "anime style",
|
|
19
|
+
"çizgi film": "cartoon style",
|
|
20
|
+
"karanlık": "dark dramatic mood",
|
|
21
|
+
"neon": "neon cyberpunk lighting",
|
|
22
|
+
"portre": "portrait photography",
|
|
23
|
+
"detaylı": "highly detailed",
|
|
24
|
+
"fantastik": "fantasy art",
|
|
25
|
+
"bilim kurgu": "science fiction",
|
|
26
|
+
"minimal": "minimalist composition"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
def load_pipelines():
|
|
30
|
+
model_id = "runwayml/stable-diffusion-v1-5"
|
|
31
|
+
pipe = StableDiffusionPipeline.from_pretrained(
|
|
32
|
+
model_id,
|
|
33
|
+
torch_dtype=dtype,
|
|
34
|
+
safety_checker=None
|
|
35
|
+
).to(device)
|
|
36
|
+
|
|
37
|
+
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="models", weight_name="ip-adapter_sd15.bin")
|
|
38
|
+
pipe.set_ip_adapter_scale(0.7)
|
|
39
|
+
|
|
40
|
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
|
41
|
+
pipe.enable_attention_slicing()
|
|
42
|
+
return pipe
|
|
43
|
+
|
|
44
|
+
_pipe = load_pipelines()
|
|
45
|
+
|
|
46
|
+
def _prepare_prompt(prompt_tr: str) -> str:
|
|
47
|
+
clean_prompt = prompt_tr.replace("#", "the person")
|
|
48
|
+
translated = translator.translate(clean_prompt)
|
|
49
|
+
prompt_lower = prompt_tr.lower()
|
|
50
|
+
|
|
51
|
+
styles = [en for tr, en in TR_STYLE_MAP.items() if tr in prompt_lower]
|
|
52
|
+
|
|
53
|
+
parts = [translated]
|
|
54
|
+
if styles:
|
|
55
|
+
parts.append(", ".join(styles))
|
|
56
|
+
parts.append("masterpiece, ultra high quality, sharp focus, professional lighting")
|
|
57
|
+
|
|
58
|
+
return ", ".join(parts)
|
|
59
|
+
|
|
60
|
+
def create_hore(prompt: str, hero: str, kalite: float = 7.5) -> str:
|
|
61
|
+
final_prompt = _prepare_prompt(prompt)
|
|
62
|
+
face_image = Image.open(hero).convert("RGB")
|
|
63
|
+
|
|
64
|
+
seed = random.randint(0, 999999999)
|
|
65
|
+
generator = torch.Generator(device=device).manual_seed(seed)
|
|
66
|
+
|
|
67
|
+
image = _pipe(
|
|
68
|
+
prompt=final_prompt,
|
|
69
|
+
ip_adapter_image=face_image,
|
|
70
|
+
negative_prompt="worst quality, low quality, blurry, bad anatomy, deformed",
|
|
71
|
+
num_inference_steps=30,
|
|
72
|
+
guidance_scale=kalite,
|
|
73
|
+
generator=generator
|
|
74
|
+
).images[0]
|
|
75
|
+
|
|
76
|
+
if os.path.exists(FIXED_OUTPUT_FILE):
|
|
77
|
+
os.remove(FIXED_OUTPUT_FILE)
|
|
78
|
+
|
|
79
|
+
image.save(FIXED_OUTPUT_FILE)
|
|
80
|
+
return os.path.abspath(FIXED_OUTPUT_FILE)
|
|
81
|
+
|
|
82
|
+
def create_hore_Bef(prompt: str, hero: str, strength: float = 0.6) -> str:
|
|
83
|
+
if not os.path.exists(FIXED_OUTPUT_FILE):
|
|
84
|
+
return create_hore(prompt, hero)
|
|
85
|
+
|
|
86
|
+
prev_image = Image.open(FIXED_OUTPUT_FILE).convert("RGB")
|
|
87
|
+
face_image = Image.open(hero).convert("RGB")
|
|
88
|
+
final_prompt = _prepare_prompt(prompt)
|
|
89
|
+
|
|
90
|
+
img2img_pipe = StableDiffusionImg2ImgPipeline(**_pipe.components)
|
|
91
|
+
|
|
92
|
+
seed = random.randint(0, 999999999)
|
|
93
|
+
generator = torch.Generator(device=device).manual_seed(seed)
|
|
94
|
+
|
|
95
|
+
image = img2img_pipe(
|
|
96
|
+
prompt=final_prompt,
|
|
97
|
+
image=prev_image,
|
|
98
|
+
ip_adapter_image=face_image,
|
|
99
|
+
strength=strength,
|
|
100
|
+
num_inference_steps=30,
|
|
101
|
+
negative_prompt="worst quality, low quality, blurry",
|
|
102
|
+
generator=generator
|
|
103
|
+
).images[0]
|
|
104
|
+
|
|
105
|
+
if os.path.exists(FIXED_OUTPUT_FILE):
|
|
106
|
+
os.remove(FIXED_OUTPUT_FILE)
|
|
107
|
+
|
|
108
|
+
image.save(FIXED_OUTPUT_FILE)
|
|
109
|
+
return os.path.abspath(FIXED_OUTPUT_FILE)
|
|
110
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vhup
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4
|
|
4
4
|
Summary: Vho: İşlevsel ve kolaylaştırılmış görsel oluşturma kütüphanesi
|
|
5
5
|
Author: Bedirhan
|
|
6
6
|
Author-email: bedirhan.oytpass@gmail.com
|
|
@@ -31,6 +31,9 @@ Requires-Dist: face_recognition
|
|
|
31
31
|
Requires-Dist: Pillow
|
|
32
32
|
Requires-Dist: insightface>=0.7.3
|
|
33
33
|
Requires-Dist: onnxruntime-gpu
|
|
34
|
+
Requires-Dist: peft
|
|
35
|
+
Requires-Dist: sentencepiece
|
|
36
|
+
Requires-Dist: protobuf
|
|
34
37
|
Dynamic: author
|
|
35
38
|
Dynamic: author-email
|
|
36
39
|
Dynamic: classifier
|
vhup-0.2/vhup/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .vhup import create_text
|
{vhup-0.2 → vhup-0.4}/LICENSE
RENAMED
|
File without changes
|
{vhup-0.2 → vhup-0.4}/README.md
RENAMED
|
File without changes
|
{vhup-0.2 → vhup-0.4}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|