File size: 2,125 Bytes
af9e16e
 
 
 
 
 
 
 
 
 
 
044983f
af9e16e
 
 
 
 
 
 
 
 
 
 
 
 
216676e
af9e16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f36e60
af9e16e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gradio as gr
#import openai
import requests
#import json
#from PIL import Image
#from io import BytesIO
import os



def generate_text_descriptions(concept):
    api_key = os.environ.get("api_key")

    concept = concept
    user_id = "user_123"  # Unique ID used to track conversation state
    body = {"action": {"type": "text", "payload": concept}}

    # Start a conversation
    response = requests.post(
        f"https://general-runtime.voiceflow.com/state/user/{user_id}/interact",
        json=body,
        headers={"Authorization": api_key},
    )


    return response.json()[0]['payload']['message'].strip("\n")



def generate_shots(prompt):
    persona = "You are an award winning cinematographer"
    prompt_shot = f"{persona} create an interesting shot using different camera angles for the concept enclosed in three backticks ```{prompt}```."
    prompt_lighting = f"{persona} create Lighting Design for the concept enclosed in three backticks ```{prompt}``` and provide description for your choice."
    prompt_color_grading = f"{persona} Create Color Grading for the concept enclosed in three backticks ```{prompt}``` and provide description for your choice."

    shot_description = generate_text_descriptions(prompt_shot)
    lighting_description = generate_text_descriptions(prompt_lighting)
    color_grading_description = generate_text_descriptions(prompt_color_grading)


    return shot_description, lighting_description, color_grading_description

def generate_output(prompt):
    shots, lighting, color_grading = generate_shots(prompt)

    return shots, lighting, color_grading
    

input_text = gr.inputs.Textbox(lines=5, label="Please provide the concept of your film to generate shot compositions, lighting designs, and color grading styles.")

iface = gr.Interface(fn=generate_output, inputs=input_text, outputs=["text", "text", "text"], label = ["shot angles", "lighting design", "color grading"],
                     layout="vertical", title="CinemAI", description="Your AI assistant that generates shot compositions, lighting designs, and color grading styles.")

iface.launch()