Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
from flask import Flask, render_template, request, send_file
|
2 |
-
|
3 |
-
from google.
|
4 |
import base64
|
5 |
import os
|
6 |
import io
|
7 |
import unicodedata
|
8 |
-
|
9 |
app = Flask(__name__)
|
10 |
|
11 |
-
|
12 |
-
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
13 |
|
14 |
def emoji_to_text(emoji):
|
15 |
try:
|
@@ -20,7 +18,7 @@ def emoji_to_text(emoji):
|
|
20 |
def is_emoji(text):
|
21 |
import re
|
22 |
emoji_pattern = re.compile(
|
23 |
-
"["
|
24 |
"\U0001F000-\U0001F9FF"
|
25 |
"\U0001F300-\U0001F5FF"
|
26 |
"\U00002702-\U000027B0"
|
@@ -29,22 +27,26 @@ def is_emoji(text):
|
|
29 |
|
30 |
return bool(emoji_pattern.fullmatch(text))
|
31 |
|
|
|
32 |
def generate_creepy_emoji(emoji):
|
33 |
description = emoji_to_text(emoji)
|
34 |
-
|
|
|
35 |
model="gemini-2.0-flash-exp-image-generation",
|
36 |
-
contents=(
|
|
|
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.
|
38 |
-
If it is not a face emoji, add a face to the image. If it is a cat face emoji, make sure you include the cat aspects in the emoji
|
39 |
-
Plan out what you are going to generate before,
|
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**:
|
47 |
-
"""
|
|
|
48 |
config=types.GenerateContentConfig(
|
49 |
response_modalities=[
|
50 |
"image",
|
@@ -78,5 +80,6 @@ def generate():
|
|
78 |
else:
|
79 |
return {"error": "No image generated."}, 400
|
80 |
|
|
|
81 |
if __name__ == "__main__":
|
82 |
app.run(host="0.0.0.0", port=7860)
|
|
|
1 |
from flask import Flask, render_template, request, send_file
|
2 |
+
from google import genai
|
3 |
+
from google.genai import types
|
4 |
import base64
|
5 |
import os
|
6 |
import io
|
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:
|
|
|
18 |
def is_emoji(text):
|
19 |
import re
|
20 |
emoji_pattern = re.compile(
|
21 |
+
"["
|
22 |
"\U0001F000-\U0001F9FF"
|
23 |
"\U0001F300-\U0001F5FF"
|
24 |
"\U00002702-\U000027B0"
|
|
|
27 |
|
28 |
return bool(emoji_pattern.fullmatch(text))
|
29 |
|
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.
|
39 |
+
If it is not a face emoji, add a face to the image. If it is a cat face emoji, make sure you include the cat aspects in the emoji
|
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",
|
|
|
80 |
else:
|
81 |
return {"error": "No image generated."}, 400
|
82 |
|
83 |
+
|
84 |
if __name__ == "__main__":
|
85 |
app.run(host="0.0.0.0", port=7860)
|