Spaces:
Runtime error
Runtime error
from gradio_client import Client | |
import gradio as gr | |
def answer_question(question): | |
global chatbot | |
information = retrieval.predict(question, api_name = "/predict") | |
answer=chat_client.predict( | |
info + information + q_prompt + question, # str in 'Type an input and press Enter' Textbox component | |
chatbot, | |
fn_index=1 | |
) | |
chatbot = answer[1] | |
return answer[1][0][1] | |
def fashion(question): | |
output = answer_question(question) | |
image = image_client.predict( | |
"A Model Wearing " + output, # str in 'What you want the AI to generate. 77 Token Limit.' Textbox component | |
"blurry, cropped, nsfw, badhands, disfigured", # str in 'What you Do Not want the AI to generate. 77 Token Limit' Textbox component | |
512, # int | float (numeric value between 512 and 1024) in 'Height' Slider component | |
512, # int | float (numeric value between 512 and 1024) in 'Width' Slider component | |
9, # int | float (numeric value between 1 and 15) in 'scale' Slider component | |
25, # int | float (numeric value between 25 and 100) in 'steps' Slider component | |
23465432238, # int | float (numeric value between 1 and 9999999999999999) in 'seed' Slider component | |
"Yes", # str in 'Upscale?' Radio component | |
api_name="/predict" | |
) | |
return None, output, image | |
chat_client = Client("https://mosaicml-mpt-30b-chat.hf.space/", serialize = False) | |
retrieval = Client("https://warlord-k-latestfashion.hf.space/") | |
image_client = Client("https://manjushri-photoreal-v2.hf.space/") | |
init_prompt ="## Instruction: You are a fashion expert and must return truthful responses as per the information. Do not answer with any information which isn't completely verified and correct. Do not lie. Do not present information where you don't know the answer. Do not include incorrect extra information. Your name is DesAIner. You are helpful and truthful. You provide fashion suggestions to shoppers based upon their latest purchases and the latest fahion trends." | |
info="Latest Fashion Trends: \n" | |
q_prompt="\n ##Instruction: Please provide fashion recommendation for the following query in less than 3 lines, specifying the clothing items and accesories: \n" | |
chatbot = [["", None]] | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
inp = gr.inputs.Textbox(label = "Question") | |
with gr.Column(): | |
display = gr.outputs.Image(type = "filepath", label = "Outfit") | |
output = gr.outputs.Textbox(label = "Suggestion") | |
btn = gr.Button(label = "Run") | |
btn.click(fashion, inputs = [inp], outputs = [inp, output, display]) | |
if __name__ == "__main__": | |
demo.launch() | |