gokaygokay
commited on
Commit
•
a06b33f
1
Parent(s):
78506fe
api_key
Browse files
app.py
CHANGED
@@ -272,8 +272,10 @@ class GPT4MiniNode:
|
|
272 |
|
273 |
print(f"Prompt saved to {filename}")
|
274 |
|
275 |
-
def generate(self, input_text, happy_talk, compress, compression_level, poster, custom_base_prompt=""):
|
276 |
try:
|
|
|
|
|
277 |
default_happy_prompt = """Create a detailed visually descriptive caption of this description, which will be used as a prompt for a text to image AI system (caption only, no instructions like "create an image").Remove any mention of digital artwork or artwork style. Give detailed visual descriptions of the character(s), including ethnicity, skin tone, expression etc. Imagine using keywords for a still for someone who has aphantasia. Describe the image style, e.g. any photographic or art styles / techniques utilized. Make sure to fully describe all aspects of the cinematography, with abundant technical details and visual descriptions. If there is more than one image, combine the elements and characters from all of the images creatively into a single cohesive composition with a single background, inventing an interaction between the characters. Be creative in combining the characters into a single cohesive scene. Focus on two primary characters (or one) and describe an interesting interaction between them, such as a hug, a kiss, a fight, giving an object, an emotional reaction / interaction. If there is more than one background in the images, pick the most appropriate one. Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph. If you feel the images are inappropriate, invent a new scene / characters inspired by these. Additionally, incorporate a specific movie director's visual style (e.g. Wes Anderson, Christopher Nolan, Quentin Tarantino) and describe the lighting setup in detail, including the type, color, and placement of light sources to create the desired mood and atmosphere. Always frame the scene as a screen grab from a 35mm film still, including details about the film grain, color grading, and any artifacts or characteristics specific to 35mm film photography."""
|
278 |
|
279 |
default_simple_prompt = """Create a brief, straightforward caption for this description, suitable for a text-to-image AI system. Focus on the main elements, key characters, and overall scene without elaborate details. Provide a clear and concise description in one or two sentences."""
|
@@ -382,6 +384,7 @@ def create_interface():
|
|
382 |
)
|
383 |
|
384 |
with gr.Tab("GPT4 Mini Text Generator"):
|
|
|
385 |
input_text = gr.Textbox(label="Input Text", lines=5)
|
386 |
happy_talk = gr.Checkbox(label="Happy Talk", value=True)
|
387 |
compress = gr.Checkbox(label="Compress", value=False)
|
@@ -394,7 +397,7 @@ def create_interface():
|
|
394 |
|
395 |
generate_text_button.click(
|
396 |
gpt4_mini_node.generate,
|
397 |
-
inputs=[input_text, happy_talk, compress, compression_level, poster, custom_base_prompt],
|
398 |
outputs=text_output
|
399 |
)
|
400 |
|
|
|
272 |
|
273 |
print(f"Prompt saved to {filename}")
|
274 |
|
275 |
+
def generate(self, api_key, input_text, happy_talk, compress, compression_level, poster, custom_base_prompt=""):
|
276 |
try:
|
277 |
+
# Initialize the OpenAI client with the provided API key
|
278 |
+
self.client = OpenAI(api_key=api_key)
|
279 |
default_happy_prompt = """Create a detailed visually descriptive caption of this description, which will be used as a prompt for a text to image AI system (caption only, no instructions like "create an image").Remove any mention of digital artwork or artwork style. Give detailed visual descriptions of the character(s), including ethnicity, skin tone, expression etc. Imagine using keywords for a still for someone who has aphantasia. Describe the image style, e.g. any photographic or art styles / techniques utilized. Make sure to fully describe all aspects of the cinematography, with abundant technical details and visual descriptions. If there is more than one image, combine the elements and characters from all of the images creatively into a single cohesive composition with a single background, inventing an interaction between the characters. Be creative in combining the characters into a single cohesive scene. Focus on two primary characters (or one) and describe an interesting interaction between them, such as a hug, a kiss, a fight, giving an object, an emotional reaction / interaction. If there is more than one background in the images, pick the most appropriate one. Your output is only the caption itself, no comments or extra formatting. The caption is in a single long paragraph. If you feel the images are inappropriate, invent a new scene / characters inspired by these. Additionally, incorporate a specific movie director's visual style (e.g. Wes Anderson, Christopher Nolan, Quentin Tarantino) and describe the lighting setup in detail, including the type, color, and placement of light sources to create the desired mood and atmosphere. Always frame the scene as a screen grab from a 35mm film still, including details about the film grain, color grading, and any artifacts or characteristics specific to 35mm film photography."""
|
280 |
|
281 |
default_simple_prompt = """Create a brief, straightforward caption for this description, suitable for a text-to-image AI system. Focus on the main elements, key characters, and overall scene without elaborate details. Provide a clear and concise description in one or two sentences."""
|
|
|
384 |
)
|
385 |
|
386 |
with gr.Tab("GPT4 Mini Text Generator"):
|
387 |
+
api_key = gr.Textbox(label="OpenAI API Key", type="password", placeholder="Enter your OpenAI API key")
|
388 |
input_text = gr.Textbox(label="Input Text", lines=5)
|
389 |
happy_talk = gr.Checkbox(label="Happy Talk", value=True)
|
390 |
compress = gr.Checkbox(label="Compress", value=False)
|
|
|
397 |
|
398 |
generate_text_button.click(
|
399 |
gpt4_mini_node.generate,
|
400 |
+
inputs=[api_key, input_text, happy_talk, compress, compression_level, poster, custom_base_prompt],
|
401 |
outputs=text_output
|
402 |
)
|
403 |
|