Spaces:
Runtime error
Runtime error
Singularity666
commited on
Commit
•
b3900cd
1
Parent(s):
7f6295c
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
!pip install sentencepiece
|
2 |
!pip install git+https://github.com/huggingface/transformers.git@cae78c46
|
3 |
!pip install diffusers
|
@@ -8,19 +9,18 @@
|
|
8 |
!pip install gradio==4.12.0
|
9 |
!pip install gradio_client==0.8.0
|
10 |
!pip install -i https://download.pytorch.org/whl/cu118 torch==2.0 torchvision==0.15 torchaudio==2.0
|
11 |
-
|
|
|
12 |
import dataclasses
|
13 |
from enum import auto, Enum
|
14 |
from typing import List, Tuple
|
15 |
|
16 |
-
|
17 |
class SeparatorStyle(Enum):
|
18 |
"""Different separator style."""
|
19 |
SINGLE = auto()
|
20 |
TWO = auto()
|
21 |
MPT = auto()
|
22 |
|
23 |
-
|
24 |
@dataclasses.dataclass
|
25 |
class Conversation:
|
26 |
"""A class that keeps all conversation history."""
|
@@ -376,7 +376,8 @@ conv_templates = {
|
|
376 |
|
377 |
if __name__ == "__main__":
|
378 |
print(default_conversation.get_prompt())
|
379 |
-
|
|
|
380 |
from typing import List, Optional, Tuple, Union
|
381 |
|
382 |
import torch
|
@@ -397,11 +398,9 @@ DEFAULT_IMAGE_PATCH_TOKEN = "<im_patch>"
|
|
397 |
DEFAULT_IM_START_TOKEN = "<im_start>"
|
398 |
DEFAULT_IM_END_TOKEN = "<im_end>"
|
399 |
|
400 |
-
|
401 |
class LlavaConfig(LlamaConfig):
|
402 |
model_type = "llava"
|
403 |
|
404 |
-
|
405 |
class LlavaLlamaModel(LlamaModel):
|
406 |
config_class = LlavaConfig
|
407 |
|
@@ -778,7 +777,8 @@ class LlavaLlamaForCausalLM(LlamaForCausalLM):
|
|
778 |
|
779 |
AutoConfig.register("llava", LlavaConfig)
|
780 |
AutoModelForCausalLM.register(LlavaConfig, LlavaLlamaForCausalLM)
|
781 |
-
|
|
|
782 |
from google.colab import drive
|
783 |
drive.mount('/content/drive')
|
784 |
|
@@ -793,9 +793,6 @@ import huggingface_hub
|
|
793 |
|
794 |
CKPT_DIR = '/content/drive/My Drive/_ckpt'
|
795 |
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
def crop_resize(f, sz=512):
|
800 |
w, h = f.size
|
801 |
if w > h:
|
@@ -908,4 +905,4 @@ with gr.Blocks() as app:
|
|
908 |
btn_sub = gr.Button('Submit')
|
909 |
btn_sub.click(fn=go_mgie, inputs=[inp, txt, seed, cfg_txt, cfg_img], outputs=[res, out])
|
910 |
|
911 |
-
app.launch()
|
|
|
1 |
+
# Install required packages
|
2 |
!pip install sentencepiece
|
3 |
!pip install git+https://github.com/huggingface/transformers.git@cae78c46
|
4 |
!pip install diffusers
|
|
|
9 |
!pip install gradio==4.12.0
|
10 |
!pip install gradio_client==0.8.0
|
11 |
!pip install -i https://download.pytorch.org/whl/cu118 torch==2.0 torchvision==0.15 torchaudio==2.0
|
12 |
+
|
13 |
+
# conversation.py
|
14 |
import dataclasses
|
15 |
from enum import auto, Enum
|
16 |
from typing import List, Tuple
|
17 |
|
|
|
18 |
class SeparatorStyle(Enum):
|
19 |
"""Different separator style."""
|
20 |
SINGLE = auto()
|
21 |
TWO = auto()
|
22 |
MPT = auto()
|
23 |
|
|
|
24 |
@dataclasses.dataclass
|
25 |
class Conversation:
|
26 |
"""A class that keeps all conversation history."""
|
|
|
376 |
|
377 |
if __name__ == "__main__":
|
378 |
print(default_conversation.get_prompt())
|
379 |
+
|
380 |
+
# mgie_llava.py
|
381 |
from typing import List, Optional, Tuple, Union
|
382 |
|
383 |
import torch
|
|
|
398 |
DEFAULT_IM_START_TOKEN = "<im_start>"
|
399 |
DEFAULT_IM_END_TOKEN = "<im_end>"
|
400 |
|
|
|
401 |
class LlavaConfig(LlamaConfig):
|
402 |
model_type = "llava"
|
403 |
|
|
|
404 |
class LlavaLlamaModel(LlamaModel):
|
405 |
config_class = LlavaConfig
|
406 |
|
|
|
777 |
|
778 |
AutoConfig.register("llava", LlavaConfig)
|
779 |
AutoModelForCausalLM.register(LlavaConfig, LlavaLlamaForCausalLM)
|
780 |
+
|
781 |
+
# main.py
|
782 |
from google.colab import drive
|
783 |
drive.mount('/content/drive')
|
784 |
|
|
|
793 |
|
794 |
CKPT_DIR = '/content/drive/My Drive/_ckpt'
|
795 |
|
|
|
|
|
|
|
796 |
def crop_resize(f, sz=512):
|
797 |
w, h = f.size
|
798 |
if w > h:
|
|
|
905 |
btn_sub = gr.Button('Submit')
|
906 |
btn_sub.click(fn=go_mgie, inputs=[inp, txt, seed, cfg_txt, cfg_img], outputs=[res, out])
|
907 |
|
908 |
+
app.launch()
|