Spaces:
Paused
Paused
use new images
Browse files- app.py +20 -7
- blonder.jpeg +0 -0
- bouts_banner.png +0 -3
- bouts_city.png +0 -0
- ex1-1.jpeg +0 -0
- ex1-2.jpeg +0 -0
- ex1-3.jpeg +0 -0
- ex2-1.jpeg +0 -0
- ex2-2.jpeg +0 -0
- ex2-3.jpeg +0 -0
- gainsborough.jpeg +0 -0
app.py
CHANGED
@@ -30,6 +30,8 @@ model = model.to(device).half()
|
|
30 |
clip_model, preprocess = clip.load("ViT-L/14", device=device)
|
31 |
gender_learn = load_learner('gender_model.pkl')
|
32 |
gender_labels = gender_learn.dls.vocab
|
|
|
|
|
33 |
|
34 |
n_inputs = 5
|
35 |
|
@@ -123,28 +125,39 @@ def run_image_mixer(args):
|
|
123 |
def is_female(img):
|
124 |
pred,pred_idx,probs = gender_learn.predict(img)
|
125 |
return float(probs[0]) > float(probs[1])
|
|
|
|
|
|
|
|
|
126 |
|
127 |
|
128 |
import gradio
|
129 |
|
130 |
def boutsify(person):
|
|
|
131 |
female_detected = is_female(person)
|
132 |
|
133 |
if female_detected:
|
134 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
person_image = Image.fromarray(person)
|
137 |
|
138 |
inputs = [
|
139 |
"Image", "Image", "Image", "Image", "Nothing",
|
140 |
"","","","","",
|
141 |
-
Image.open(
|
142 |
-
Image.open("
|
143 |
-
Image.open("
|
144 |
person_image,
|
145 |
-
|
146 |
-
1.
|
147 |
-
3.0, 1, random.randrange(0, 10000),
|
148 |
]
|
149 |
|
150 |
return run_image_mixer(inputs)
|
|
|
30 |
clip_model, preprocess = clip.load("ViT-L/14", device=device)
|
31 |
gender_learn = load_learner('gender_model.pkl')
|
32 |
gender_labels = gender_learn.dls.vocab
|
33 |
+
beard_learn = load_learner('facial_hair_model.pkl')
|
34 |
+
beard_labels = beard_learn.dls.vocab
|
35 |
|
36 |
n_inputs = 5
|
37 |
|
|
|
125 |
def is_female(img):
|
126 |
pred,pred_idx,probs = gender_learn.predict(img)
|
127 |
return float(probs[0]) > float(probs[1])
|
128 |
+
|
129 |
+
def has_beard(img):
|
130 |
+
pred,pred_idx,probs = beard_learn.predict(img)
|
131 |
+
return float(probs[0]) > float(probs[1])
|
132 |
|
133 |
|
134 |
import gradio
|
135 |
|
136 |
def boutsify(person):
|
137 |
+
portrait_path = "bouts_m1.jpg"
|
138 |
female_detected = is_female(person)
|
139 |
|
140 |
if female_detected:
|
141 |
+
print("This is a female portrait")
|
142 |
+
portrait_path = "bouts_f1.jpg"
|
143 |
+
else:
|
144 |
+
print("This is a male portrait")
|
145 |
+
if has_beard(person):
|
146 |
+
print("The person has a beard")
|
147 |
+
portrait_path = "bouts_mb1.jpg"
|
148 |
|
149 |
person_image = Image.fromarray(person)
|
150 |
|
151 |
inputs = [
|
152 |
"Image", "Image", "Image", "Image", "Nothing",
|
153 |
"","","","","",
|
154 |
+
Image.open(portrait_path).convert("RGB"),
|
155 |
+
Image.open("boutsback_o1.png").convert("RGB"),
|
156 |
+
Image.open("boutsback_o2.png").convert("RGB"),
|
157 |
person_image,
|
158 |
+
"",
|
159 |
+
1.1,1,1,1.4,1,
|
160 |
+
3.0, 1, random.randrange(0, 10000), 50,
|
161 |
]
|
162 |
|
163 |
return run_image_mixer(inputs)
|
blonder.jpeg
DELETED
Binary file (308 kB)
|
|
bouts_banner.png
DELETED
Git LFS Details
|
bouts_city.png
DELETED
Binary file (720 kB)
|
|
ex1-1.jpeg
DELETED
Binary file (139 kB)
|
|
ex1-2.jpeg
DELETED
Binary file (146 kB)
|
|
ex1-3.jpeg
DELETED
Binary file (85.2 kB)
|
|
ex2-1.jpeg
DELETED
Binary file (119 kB)
|
|
ex2-2.jpeg
DELETED
Binary file (271 kB)
|
|
ex2-3.jpeg
DELETED
Binary file (18.3 kB)
|
|
gainsborough.jpeg
DELETED
Binary file (155 kB)
|
|