Spaces:
Sleeping
Sleeping
File size: 3,563 Bytes
7ecd3a9 86335ae 7ecd3a9 f35cb88 | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | from Promptless_LLM_Agent import questions
from Summarization import Summarizer
from TextToImage_StableDiffusion import generate as image_generator
import random
import gradio as gr
user_defined_questions = ["What is the title or subject of the video? Please provide a brief description (1-2 sentences) to help me understand the content?",
"What type of video is this (e.g., documentary, informative, sarcastic, comedy, tutorial, review, etc.)?",
"Are there any specific keywords or tags you want to include for search optimization? ",
"What is the desired mood or atmosphere for the thumbnail (e.g., energetic, calm, inspirational, humorous)?",
"What style or tone do you want to convey (e.g., serious, playful, minimalist, detailed)?",
"Are there any specific text elements (e.g., titles, subtitles, quotes) you want to include in the thumbnail?",
"Who is the target audience for this video?"]
def nextGen():
try:
x = next(q)
except StopIteration:
x = None
return x
def requirement_string(req, QA):
req = "User Requirement: "+req+"\n"
for q, a in QA:
req = req+'\n'+'Graphic Designer: '+q+'\n'+'User: '+a
return req
r = None
q = None
qa = None
summary = None
with gr.Blocks() as demo:
title = gr.Label(value="Graphic Designer", show_label=False)
a = gr.Textbox(label="Enter Requirement")
b = gr.Button("Submit")
c = gr.Label(visible=False)
d = gr.Chatbot(visible=False)
g = gr.Textbox(visible=False)
e = gr.Textbox(visible=False)
f = gr.Button(visible=False)
h = gr.Label(visible=False)
m = gr.Image(visible=False)
def fn_req(data):
global r
global q
r = data[a]
try:
llm_q = questions(data[a])
llm_q = random.sample(llm_q, 3)
except:
llm_q = []
all_q = user_defined_questions + llm_q
q = (i for i in all_q)
return {a: gr.Textbox(visible=False),
b: gr.Button(visible=False),
c: gr.Label(value=data[a], label="Customer Requirement", visible=True),
d: gr.Chatbot(label="Requirements Gathering", visible=True),
g: gr.Textbox(value=nextGen(), label="Question", visible=True),
e: gr.Textbox(label="Answer", visible=True),
f: gr.Button("Submit Answer", visible=True)}
def bot_user_response(question, answer, history):
global qa
global summary
history = history + [[question, answer]]
question = nextGen()
if question:
return {g: question, e: '', d: history}
else:
qa = requirement_string(r, history)
summary = Summarizer(qa)
# summary = """The user requires a YouTube thumbnail for an educational video.
# They want a dancer to be featured in the image and
# the tone or mood they want to convey is joyful."""
image = image_generator(summary)
text = "Thank you for your response"
return {g: gr.Textbox(visible=False),
e: gr.Textbox(visible=False),
d: history,
h: gr.Label(value=text, visible=True, show_label=False),
f: gr.Button(visible=False),
m: gr.Image(value=image ,visible=True)}
b.click(fn=fn_req, inputs={a}, outputs=[a,b,c,d,g,e,f])
f.click(bot_user_response, [g, e, d], [g, e, d, h, f, m])
demo.launch() |