Skip to content

Commit

Permalink
fix some imports
Browse files Browse the repository at this point in the history
  • Loading branch information
BabyChouSr committed Nov 11, 2023
1 parent f1602bf commit 8173ee3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 73 deletions.
8 changes: 2 additions & 6 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@
from fastchat.model.model_codet5p import generate_stream_codet5p
from fastchat.model.model_falcon import generate_stream_falcon
from fastchat.model.model_exllama import generate_stream_exllama
from fastchat.model.llava.model_llava import (
generate_stream_llava,
LLAVA_IM_START_TOKEN,
LLAVA_IM_END_TOKEN,
LLAVA_IMAGE_PATCH_TOKEN,
)
from fastchat.model.llava.constants import LLAVA_IM_START_TOKEN, LLAVA_IM_END_TOKEN, LLAVA_IMAGE_PATCH_TOKEN
from fastchat.model.llava.model_llava import generate_stream_llava
from fastchat.model.llava.language_model.llava_llama import LlavaLlamaForCausalLM
from fastchat.model.model_xfastertransformer import generate_stream_xft
from fastchat.model.monkey_patch_non_inplace import (
Expand Down
File renamed without changes
File renamed without changes
79 changes: 12 additions & 67 deletions fastchat/serve/gradio_web_server_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
flag_last_response,
post_process_code,
get_model_description_md,
headers,
no_change_btn,
enable_btn,
disable_btn,
invisible_btn,
enable_moderation,
acknowledgment_md,
block_css,
controller_url
)
from fastchat.model.llava.constants import LLAVA_IMAGE_TOKEN
from fastchat.model.model_adapter import get_conversation_template
Expand All @@ -56,28 +65,6 @@


logger = build_logger("gradio_web_server", "gradio_web_server.log")

headers = {"User-Agent": "FastChat Client"}

no_change_btn = gr.Button.update()
enable_btn = gr.Button.update(interactive=True, visible=True)
disable_btn = gr.Button.update(interactive=False)
invisible_btn = gr.Button.update(interactive=False, visible=False)

controller_url = None
enable_moderation = False

acknowledgment_md = """
### Acknowledgment
<div class="image-container">
<p> We thank <a href="https://www.kaggle.com/" target="_blank">Kaggle</a>, <a href="https://mbzuai.ac.ae/" target="_blank">MBZUAI</a>, <a href="https://www.anyscale.com/" target="_blank">AnyScale</a>, and <a href="https://huggingface.co/" target="_blank">HuggingFace</a> for their <a href="https://lmsys.org/donations/" target="_blank">sponsorship</a>. </p>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Kaggle_logo.png/400px-Kaggle_logo.png" alt="Image 1">
<img src="https://mma.prnewswire.com/media/1227419/MBZUAI_Logo.jpg?p=facebookg" alt="Image 2">
<img src="https://docs.anyscale.com/site-assets/logo.png" alt="Image 3">
<img src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png" alt="Image 4">
</div>
"""

ip_expiration_dict = defaultdict(lambda: 0)

# Information about custom OpenAI compatible API models.
Expand Down Expand Up @@ -378,48 +365,6 @@ def bot_response(state, temperature, top_p, max_new_tokens, request: gr.Request)
}
fout.write(json.dumps(data) + "\n")


block_css = """
#notice_markdown {
font-size: 104%
}
#notice_markdown th {
display: none;
}
#notice_markdown td {
padding-top: 6px;
padding-bottom: 6px;
}
#leaderboard_markdown {
font-size: 104%
}
#leaderboard_markdown td {
padding-top: 6px;
padding-bottom: 6px;
}
#leaderboard_dataframe td {
line-height: 0.1em;
}
#input_box textarea {
}
footer {
display:none !important
}
.image-container {
display: flex;
align-items: center;
padding: 1px;
}
.image-container img {
margin: 0 30px;
height: 20px;
max-height: 100%;
width: auto;
max-width: 20%;
}
"""


def build_single_vision_language_model_ui(models, add_promotion_links=False):
promotion = (
"""
Expand Down Expand Up @@ -508,8 +453,8 @@ def build_single_vision_language_model_ui(models, add_promotion_links=False):

gr.Examples(
examples=[
[f"{cur_dir}/examples/dog.jpeg", "What animal is in this photo?"],
[f"{cur_dir}/examples/sunset.jpg", "Where was this picture taken?"],
[f"{cur_dir}/example_images/dog.jpeg", "What animal is in this photo?"],
[f"{cur_dir}/example_images/sunset.jpg", "Where was this picture taken?"],
],
inputs=[imagebox, textbox],
)
Expand Down Expand Up @@ -571,7 +516,7 @@ def build_single_vision_language_model_ui(models, add_promotion_links=False):

def build_demo(models):
with gr.Blocks(
title="Chat with Open Large Language Models",
title="Chat with Open Large Vision-Language Models",
theme=gr.themes.Default(),
css=block_css,
) as demo:
Expand Down
Binary file removed playground/images/python.png
Binary file not shown.
Binary file removed playground/images/sunset.jpg
Binary file not shown.

0 comments on commit 8173ee3

Please sign in to comment.