Spaces:
Runtime error
Runtime error
Kvikontent
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ from PIL import Image
|
|
5 |
import os
|
6 |
import random
|
7 |
import faker
|
|
|
8 |
|
9 |
# Setting up API endpoints and headers
|
10 |
face_api_url = "https://api-inference.huggingface.co/models/stablediffusionapi/realvis-xl-v40"
|
@@ -32,7 +33,7 @@ def generate_random_surname():
|
|
32 |
# Function to generate a random birth date
|
33 |
def generate_random_birth_date():
|
34 |
fake = faker.Faker()
|
35 |
-
return fake.date_of_birth().strftime("%m/%d/%Y")
|
36 |
|
37 |
# Function to generate a random 6-digit number for fingerprint generation
|
38 |
def generate_random_number():
|
@@ -59,8 +60,14 @@ st.write(f"Name: {name}")
|
|
59 |
st.write(f"Surname: {surname}")
|
60 |
st.write(f"Birth Date: {birth_date}")
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
# Generate face image based on age
|
63 |
-
age = 30
|
64 |
st.write(f"Photo of {age} years old {gender} with serious face:")
|
65 |
face_image = generate_face_image(age, gender)
|
66 |
st.image(face_image, caption=f"{age} years old {gender}")
|
|
|
5 |
import os
|
6 |
import random
|
7 |
import faker
|
8 |
+
import datetime
|
9 |
|
10 |
# Setting up API endpoints and headers
|
11 |
face_api_url = "https://api-inference.huggingface.co/models/stablediffusionapi/realvis-xl-v40"
|
|
|
33 |
# Function to generate a random birth date
|
34 |
def generate_random_birth_date():
|
35 |
fake = faker.Faker()
|
36 |
+
return fake.date_of_birth(minimum_age=18, maximum_age=80).strftime("%m/%d/%Y")
|
37 |
|
38 |
# Function to generate a random 6-digit number for fingerprint generation
|
39 |
def generate_random_number():
|
|
|
60 |
st.write(f"Surname: {surname}")
|
61 |
st.write(f"Birth Date: {birth_date}")
|
62 |
|
63 |
+
# Calculate age based on birth year
|
64 |
+
birth_year = int(birth_date[-4:])
|
65 |
+
current_year = datetime.datetime.now().year
|
66 |
+
age = current_year - birth_year
|
67 |
+
|
68 |
+
st.write(f"Age: {age}")
|
69 |
+
|
70 |
# Generate face image based on age
|
|
|
71 |
st.write(f"Photo of {age} years old {gender} with serious face:")
|
72 |
face_image = generate_face_image(age, gender)
|
73 |
st.image(face_image, caption=f"{age} years old {gender}")
|