Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import io
|
|
7 |
import unicodedata
|
8 |
app = Flask(__name__)
|
9 |
|
10 |
-
genai.
|
11 |
|
12 |
def emoji_to_text(emoji):
|
13 |
try:
|
@@ -30,8 +30,9 @@ def is_emoji(text):
|
|
30 |
|
31 |
def generate_creepy_emoji(emoji):
|
32 |
description = emoji_to_text(emoji)
|
33 |
-
|
34 |
-
response =
|
|
|
35 |
contents=(
|
36 |
f"""
|
37 |
Generate a hyper-realistic and highly detailed image of the {emoji} emoji. This image should depict a **realistic, textured**, and **wrinkled** version of the {description} emoji, transforming it into an unsettling and eerie representation.
|
@@ -39,22 +40,27 @@ def generate_creepy_emoji(emoji):
|
|
39 |
Plan out what you are going to generate before, make sure you understand what the emoji contains in itself.
|
40 |
Make sure you generate the image as well as the prompt
|
41 |
|
42 |
-
- **Facial Features**: The skin should appear aged, with deep wrinkles, pores, and imperfections, making it look as lifelike as possible.
|
43 |
-
- **Texture & Detail**: The skin should have a hyper-detailed texture, including fine lines, blemishes, and realistic lighting effects to enhance the **creepy and unsettling** aesthetic.
|
44 |
-
- **Color & Lighting**: Use **appropriate colors** (typically yellow for facial emojis), ensuring **shadows and highlights** enhance realism. The lighting should create an eerie atmosphere, possibly with unnatural or dim lighting to increase the unsettling effect.
|
45 |
-
- **Mood & Style**: The image should evoke a sense of unease, making the emoji appear unnervingly lifelike, almost **uncanny valley** in effect.
|
46 |
- **Follow Emoji**: Make sure that you follow all elements that should be in the emoji, like tears, laughing tears of joy, and other liquids, as well as other things. For example the smirking emoji should be smirking, not deadpan. The laughing emoji should have tears of joy, ect...
|
47 |
"""
|
48 |
),
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
52 |
)
|
53 |
|
54 |
-
if response and response.
|
55 |
-
for
|
56 |
-
if
|
57 |
-
|
|
|
|
|
58 |
return None
|
59 |
|
60 |
@app.route("/", methods=["GET", "POST"])
|
|
|
7 |
import unicodedata
|
8 |
app = Flask(__name__)
|
9 |
|
10 |
+
genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
|
11 |
|
12 |
def emoji_to_text(emoji):
|
13 |
try:
|
|
|
30 |
|
31 |
def generate_creepy_emoji(emoji):
|
32 |
description = emoji_to_text(emoji)
|
33 |
+
client = genai.Client()
|
34 |
+
response = client.models.generate_content(
|
35 |
+
model="gemini-2.0-flash-exp-image-generation",
|
36 |
contents=(
|
37 |
f"""
|
38 |
Generate a hyper-realistic and highly detailed image of the {emoji} emoji. This image should depict a **realistic, textured**, and **wrinkled** version of the {description} emoji, transforming it into an unsettling and eerie representation.
|
|
|
40 |
Plan out what you are going to generate before, make sure you understand what the emoji contains in itself.
|
41 |
Make sure you generate the image as well as the prompt
|
42 |
|
43 |
+
- **Facial Features**: The skin should appear aged, with deep wrinkles, pores, and imperfections, making it look as lifelike as possible.
|
44 |
+
- **Texture & Detail**: The skin should have a hyper-detailed texture, including fine lines, blemishes, and realistic lighting effects to enhance the **creepy and unsettling** aesthetic.
|
45 |
+
- **Color & Lighting**: Use **appropriate colors** (typically yellow for facial emojis), ensuring **shadows and highlights** enhance realism. The lighting should create an eerie atmosphere, possibly with unnatural or dim lighting to increase the unsettling effect.
|
46 |
+
- **Mood & Style**: The image should evoke a sense of unease, making the emoji appear unnervingly lifelike, almost **uncanny valley** in effect.
|
47 |
- **Follow Emoji**: Make sure that you follow all elements that should be in the emoji, like tears, laughing tears of joy, and other liquids, as well as other things. For example the smirking emoji should be smirking, not deadpan. The laughing emoji should have tears of joy, ect...
|
48 |
"""
|
49 |
),
|
50 |
+
config=types.GenerateContentConfig(
|
51 |
+
response_modalities=[
|
52 |
+
"image",
|
53 |
+
"text",
|
54 |
+
],
|
55 |
+
),
|
56 |
)
|
57 |
|
58 |
+
if response and response.candidates:
|
59 |
+
for candidate in response.candidates:
|
60 |
+
if candidate.content and candidate.content.parts:
|
61 |
+
for part in candidate.content.parts:
|
62 |
+
if hasattr(part, "inline_data") and part.inline_data:
|
63 |
+
return part.inline_data.data
|
64 |
return None
|
65 |
|
66 |
@app.route("/", methods=["GET", "POST"])
|