\nAssistant:"
print(content)
stream = client.text_generation(prompt=content, **generation_args)
#stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=False)
#resp = ""
#for response in stream:
# resp += response.token.text
print (stream)
return stream
def generate(purpose,history,chat_drop,seed):
print (history)
out_prompt = run_gpt(purpose,history,chat_drop,seed)
return out_prompt
def describe(purpose,history,image,chat_drop,seed):
print (history)
#purpose=f"{purpose},"
out_prompt = run_idefics(purpose,history,image,chat_drop,seed)
return out_prompt
def run(purpose,history,image,model_drop,chat_drop,choice,seed):
if choice == "Generate":
#out_img = infer(out_prompt)
out_prompt=generate(purpose,history,chat_drop,seed)
history.append((purpose,out_prompt))
yield (history,None)
model=loaded_model[int(model_drop)]
out_img=model(out_prompt)
#return (history,None)
print(out_img)
url=f'https://johann22-chat-diffusion-describe.hf.space/file={out_img}'
print(url)
uid = uuid.uuid4()
#urllib.request.urlretrieve(image, 'tmp.png')
#out=Image.open('tmp.png')
r = requests.get(url, stream=True)
if r.status_code == 200:
out = Image.open(io.BytesIO(r.content))
#yield ([(purpose,out_prompt)],out)
yield (history,out)
else:
yield ([(purpose,"an Error occured")],None)
if choice == "Describe":
#out_img = infer(out_prompt)
out_prompt=describe(purpose,history,image,chat_drop,seed)
history.append((purpose,out_prompt))
yield (history,None)
################################################
style="""
.top_head{
background: no-repeat;
background-image: url(https://huggingface.co/spaces/johann22/chat-diffusion/resolve/main/image.png);
background-position-y: bottom;
height: 180px;
background-position-x: center;
}
.top_h1{
color: white!important;
-webkit-text-stroke-width: medium;
}
"""
with gr.Blocks(css=style) as iface:
gr.HTML("""
Mixtral Chat Diffusion
This chatbot will generate images