Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorg code #144

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions paddlemix/examples/blip2/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))
import os
from dataclasses import dataclass, field
import yaml

import paddle
import yaml
from paddlenlp.trainer import PdArgumentParser

from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.utils.log import logger

Expand Down
8 changes: 4 additions & 4 deletions paddlemix/examples/blip2/merge_weight.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os

from paddlemix.utils.log import logger
import sys
import argparse
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))

os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["FLAGS_use_cuda_managed_memory"] = "true"

import paddle

from paddlemix.utils.log import logger
from paddlenlp.transformers import LlamaForCausalLM
from paddlenlp.transformers.opt.modeling import OPTForCausalLM
from paddlenlp.transformers.t5.modeling import T5ForConditionalGeneration
Expand Down
5 changes: 2 additions & 3 deletions paddlemix/examples/blip2/run_eval_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))
import random
import numpy as np
from dataclasses import dataclass, field

import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker

from paddlemix.datasets import load_dataset
from paddlemix.examples.blip2.utils import BlipCollator, create_tokenizer, load_model
from paddlemix.models.blip2.utils import load_model, BlipCollator, create_tokenizer
from paddlemix.models.blip2.configuration import Blip2Config
from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.processors.blip_processing import (
Expand Down
6 changes: 3 additions & 3 deletions paddlemix/examples/blip2/run_eval_vqav2_zeroshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))
import random
import numpy as np
from dataclasses import dataclass, field

import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker

from paddlemix.datasets import load_dataset
from paddlemix.examples.blip2.utils import BlipCollator, create_tokenizer, load_model
from paddlemix.models.blip2.utils import load_model, BlipCollator, create_tokenizer
from paddlemix.models.blip2.configuration import Blip2Config
from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.processors.blip_processing import (
Expand All @@ -39,6 +38,7 @@
from paddlenlp.trainer import PdArgumentParser, TrainingArguments, get_last_checkpoint



class BlipCollator_VQA(BlipCollator):
"""
Data collator that will dynamically pad the inputs to the longest sequence in the batch.
Expand Down
12 changes: 5 additions & 7 deletions paddlemix/examples/blip2/run_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@
import os
import random
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))
import numpy as np
from dataclasses import dataclass, field
import requests
from PIL import Image

import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))

import requests
from PIL import Image

from paddlemix.examples.blip2.utils import create_tokenizer, load_model
from paddlemix.models.blip2.utils import load_model, create_tokenizer
from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.processors.blip_processing import (
Blip2Processor,
Expand Down
5 changes: 2 additions & 3 deletions paddlemix/examples/blip2/run_pretrain_stage1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
import os
import sys
import warnings

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../.."))
import random
import numpy as np
from dataclasses import dataclass, field
from typing import Optional

import numpy as np
import paddle
import paddle.distributed as dist
from paddle.distributed import fleet
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker

from paddlemix.datasets import load_dataset
from paddlemix.examples.blip2.utils import load_model
from paddlemix.models.blip2.utils import load_model
from paddlemix.models.blip2.configuration import Blip2Config
from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.processors.blip_processing import (
Expand Down
2 changes: 1 addition & 1 deletion paddlemix/examples/blip2/run_pretrain_stage2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from paddle.distributed.fleet.meta_parallel import get_rng_state_tracker

from paddlemix.datasets import load_dataset
from paddlemix.examples.blip2.utils import BlipCollator, create_tokenizer, load_model
from paddlemix.models.blip2.configuration import Blip2Config
from paddlemix.models.blip2.modeling import Blip2ForConditionalGeneration
from paddlemix.models.blip2.utils import load_model, BlipCollator, create_tokenizer
from paddlemix.processors.blip_processing import (
Blip2Processor,
BlipImageProcessor,
Expand Down
2 changes: 1 addition & 1 deletion paddlemix/models/blip2/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import paddle

from paddlemix.examples.blip2.utils import blip2_load
from paddlemix.models.model_utils import MixPretrainedModel
from paddlemix.utils.log import logger
from paddlenlp.transformers import AutoTokenizer
Expand All @@ -30,6 +29,7 @@
from paddlenlp.utils.env import PADDLE_WEIGHTS_NAME, SAFE_WEIGHTS_NAME

from .configuration import Blip2Config
from .utils import blip2_load

VISION_WEIGHTS = {"eva_vit_g": "https://bj.bcebos.com/paddlenlp/models/community/paddlemix/blip2-stage2/eva_vit_g"}
BRIDGE_WEIGHTS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import copy
import datetime
import json
Expand Down Expand Up @@ -770,4 +771,4 @@ def loadRes(self, resFile, quesFile):

res.dataset["annotations"] = anns
res.createIndex()
return res
return res