Spaces:
Runtime error
Runtime error
fancyfeast commited on
Commit ·
5a5956e
1
Parent(s): 248feb4
Man the chatinterface is weird
Browse files74 unmodified lines75767778798053 unmodified lines13413513613713813911 unmodified lines1511521531541551561573 unmodified lines1611621631641651661673 unmodified lines17117217317417517617774 unmodified linesdef chat_joycaption(message: dict, history, temperature: float, max_new_tokens: int) -> Generator[str, None, None]:torch.cuda.empty_cache()# Prompts are always stripped in training for nowprompt = message['text'].strip()53 unmodified linespixel_values = TVF.normalize(pixel_values, [0.5], [0.5])pixel_values = pixel_values.to(torch.bfloat16)generate_kwargs = dict(input_ids=input_ids,pixel_values=pixel_values,11 unmodified linesif temperature == 0:generate_kwargs["do_sample"] = Falsestreamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)t = Thread(target=model.generate, kwargs=generate_kwargs)t.start()3 unmodified linesyield "".join(outputs)chatbot=gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInterface')with gr.Blocks() as demo:gr.HTML(TITLE)3 unmodified lineschatbot=chatbot,fill_height=True,multimodal=True,additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),additional_inputs=[gr.Slider(minimum=0,maximum=1,74 unmodified lines757677787980818253 unmodified lines13613713813914014114214311 unmodified lines1551561571581591603 unmodified lines1641651661671681691701713 unmodified lines17517617717817918018118274 unmodified linesdef chat_joycaption(message: dict, history, temperature: float, max_new_tokens: int) -> Generator[str, None, None]:torch.cuda.empty_cache()print(message)# Prompts are always stripped in training for nowprompt = message['text'].strip()53 unmodified linespixel_values = TVF.normalize(pixel_values, [0.5], [0.5])pixel_values = pixel_values.to(torch.bfloat16)streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)generate_kwargs = dict(input_ids=input_ids,pixel_values=pixel_values,11 unmodified linesif temperature == 0:generate_kwargs["do_sample"] = Falset = Thread(target=model.generate, kwargs=generate_kwargs)t.start()3 unmodified linesyield "".join(outputs)chatbot=gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInterface', type="messages")textbox = gr.MultimodalTextbox(file_types=["image"], file_count="single")with gr.Blocks() as demo:gr.HTML(TITLE)3 unmodified lineschatbot=chatbot,fill_height=True,multimodal=True,textbox=textbox,additional_inputs_accordion=None,#gr.Accordion(label="⚙️ Parameters", open=False, render=False),additional_inputs=[gr.Slider(minimum=0,maximum=1,
app.py+8-3