【多模态&LLM】Reyes:一个从0到1开始训练的多模态大模型(技术报告)

最近,笔者系统的看了下一些比较经典的多模态大模型实现思路,本着动手实践的态度,从零到一实现了一个多模态大模型,并命名为Reyes(睿视),R:睿,eyes:眼。Reyes的参数量为8B,视觉编码器使用的是InternViT-300M-448px-V2_5,语言模型侧使用的是Qwen2.5-7B-Instruct,与NVLM-1.0等相关多模态大模型一样,Reyes也通过一个两层MLP投影层连接视觉编码器与语言模型。最终,Reyes-8B以更小的参数量在MMMU-benchmark得分超越llava1.5-13B。

  • 模型权重开源地址:https://modelscope.cn/models/yujunhuinlp/Reyes-8B
  • github:https://github.com/yujunhuics/Reyes

Reyes模型大体架构

Reyes模型架构

  • 视觉编码器:InternViT-300M-448px-V2_5(https://modelscope.cn/models/OpenGVLab/InternViT-300M-448px-V2_5)
  • LLM侧:Qwen2.5-7B-Instruct(https://modelscope.cn/models/Qwen/Qwen2.5-7B-Instruct)

模型实现:ReyesModel


class ReyesModel(PreTrainedModel):
    config_class = ReyesConfig
    main_input_name = 'pixel_values'
    _supports_flash_attn_2 = True
    _no_split_modules = ['InternVisionModel', 'Qwen2DecoderLayer']

    def __init__(self, config: ReyesConfig, vision_model=None, language_model=None, use_flash_attn=True):
        super().__init__(config)

        assert version_cmp(transformers.__version__, '4.44.2', 'ge')
        image_size = config.force_image_size or config.vision_config.image_size
        patch_size = config.vision_config.patch_size
        self.patch_size = patch_size
        self.select_layer = config.select_layer
        self.llm_arch_name = config.llm_config.architectures[0]
        self.template = config.template
        self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
        self.downsample_ratio = config.downsample_ratio
        self.ps_version = config.ps_version
        use_flash_attn = use_flash_attn if has_flash_attn else False
        config.vision_config.use_flash_attn = True if use_flash_attn else False
        config.llm_config._attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'

        logger.info(f'num_image_token: {self.num_image_token}')
        logger.info(f'ps_version: {self.ps_version}')
        if vision_model is not None:
            self.vision_model = vision_model
        else:
            self.vision_model = InternVisionModel(config.vision_config)
        if language_model is not None:
            self.language_model = language_model
        else:
            if config.llm_config.architectures[0] == 'Qwen2ForCausalLM':
                self.language_model = Qwen2ForCausalLM(config.llm_config)
                # self.language_model = AutoLigerKernelForCausalLM(config.llm_config)
            else:
                raise NotImplementedError(f'{config.llm_config.architectures[0]} is not implemented.')

        vit_hidden_size = config.vision_config.hidden_size
        llm_intermediate_size = config.llm_config.intermediate_size
        llm_hidden_size = config.llm_config.hidden_size

        self.mlp1 = nn.Sequential(
            nn.LayerNorm(vit_hidden_size * int(1 / self.downsample_ratio) ** 2),
            nn.Linear(vit_hidden_size * int(1 / self.downsample_ratio) ** 2, llm_intermediate_size, bias=False),
            nn.GELU(),
            nn.Linear(llm_intermediate_size, llm_hidden_size, bias=False)
        )

        self.img_context_token_id = None
        self.conv_template = get_conv_template(self.template)
        self.system_message = self.conv_template.system_message

        if config.use_backbone_lora:
            self.wrap_backbone_lora(r=config.use_backbone_lora, lora_alpha=2 * config.use_backbone_lora)

        if config.use_llm_lora:
            self.wrap_llm_lora(r=config.use_llm_lora, lora_alpha=2 * config.use_llm_lora)

    def wrap_backbone_lora(self, r=128, lora_alpha=256, lora_dropout=0.05):
        lora_config = LoraConfig(
            r=r,
            target_modules=['attn.qkv', 'attn.proj', 'mlp.fc1', 'mlp.fc2'],
            lora_alpha=lora_alpha,
            lora_dropout=lora_dropout,
        )
        self.vision_model = get_peft_model(self.vision_model, lora_config)
        self.vision_model.print_trainable_parameters()

    def wrap_llm_lora(self, r=128, lora_alpha=256, lora_dropout=0.05):
        # Determine the target modules based on the architecture of the language model
        if self.llm_arch_name in ['Qwen2ForCausalLM', 'LlamaForCausalLM']:
            target_modules = ['self_attn.q_proj', 'self_attn.k_proj', 'self_attn.v_proj', 'self_attn.o_proj',
                              'mlp.gate_proj', 'mlp.down_proj', 'mlp.up_proj']
        else:
            raise NotImplemented
        lora_config = LoraConfig(
            r=r,
            target_modules=target_modules,
            lora_alpha=lora_alpha,
            lora_dropout=lora_dropout,
            task_type='CAUSAL_LM'
        )
        self.language_model = get_peft_model(self.language_model, lora_config)
        self.language_model.enable_input_require_grads()
        self.language_model.print_trainable_parameters()

    def forward(
            self,
            pixel_values: torch.FloatTensor,
            input_ids: torch.LongTensor = None,
            attention_mask: Optional[torch.Tensor] = None,
            position_ids: Optional[torch.LongTensor] = None,
            image_flags: Optional[torch.LongTensor] = None,
            past_key_values: Optional[List[torch.FloatTensor]] = None,
            labels: Optional[torch.LongTensor] = None,
            use_cache: Optional[bool] = None,
            output_attentions: Optional[bool] = None,
            output_hidden_states: Optional[bool] = None,
            return_dict: Optional[bool] = None,
    ) -> Union[Tuple, CausalLMOutputWithPast]:
        return_dict = return_dict if return_dict is not None else self.config.use_return_dict

        # image_flags = image_flags.squeeze(-1)
        input_embeds = self.language_model.get_input_embeddings()(input_ids)

        vit_embeds = self.extract_feature(pixel_values)
        # vit_embeds = vit_embeds[image_flags == 1]
        vit_batch_size = pixel_values.shape[0]

        B, N, C = input_embeds.shape
        input_embeds = input_embeds.reshape(B * N, C)

        # if torch.distributed.get_rank() == 0:
        #     print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')

        input_ids = input_ids.reshape(B * N)
        selected = (input_ids == self.img_context_token_id)
        try:
            input_embeds[selected] = input_embeds[selected] * 0.0 + vit_embeds.reshape(-1, C)
        except Exception as e:
            vit_embeds = vit_embeds.reshape(-1, C)
            print(f'warning: {e}, input_embeds[selected].shape={input_embeds[selected].shape}, '
                  f'vit_embeds.shape={vit_embeds.shape}')
            n_token = selected.sum()
            input_embeds[selected] = input_embeds[selected] * 0.0 + vit_embeds[:n_token]

        input_embeds = input_embeds.reshape(B, N, C)

        outputs = self.language_model(
            inputs_embeds=input_embeds,
            attention_mask=attention_mask,
            position_ids=position_ids,
            past_key_values=past_key_values,
            use_cache=use_cache,
            output_attentions=output_attentions,
            output_hidden_states=output_hidden_states,
            return_dict=return_dict,
        )
        logits = outputs.logits

        loss = None
        if labels is not None:
            # Shift so that tokens < n predict n
            shift_logits = logits[..., :-1, :].contiguous()
            shift_labels = labels[..., 1:].contiguous()
            # Flatten the tokens
            loss_fct = CrossEntropyLoss()
            shift_logits = shift_logits.view(-1, self.language_model.config.vocab_size)
            shift_labels = shift_labels.view(-1)

            # Enable model parallelism
            shift_labels = shift_labels.to(shift_logits.device)
            loss = loss_fct(shift_logits, shift_labels)

        if not return_dict:
            output = (logits,) + outputs[1:]
            return (loss,) + output if loss is not None else output

        return CausalLMOutputWithPast(
            loss=loss,
            logits=logits,
            past_key_values=outputs.past_key_values,
            hidden_states=outputs.hidden_states,
            attentions=outputs.attentions,
        )

数据引擎

  • 预训练数据(558k):https://huggingface.co/datasets/liuhaotian/LLaVA-Pretrain

  • SFT数据(665k,其实笔者没使用这么多,大概使用了430K左右):https://huggingface.co/datasets/liuhaotian/LLaVA-Instruct-150K/blob/main/llava_v1_5_mix665k.json

    图片放置方式:

    ├── coco
    │   └── train2017
    ├── gqa
    │   └── images
    ├── ocr_vqa
    │   └── images
    ├── textvqa
    │   └── train_images
    └── vg
        ├── VG_100K
        └── VG_100K_2
    
数据格式
  • 预训练数据格式:

    <Image><image></Image> Give a brief description of the image. A group of airplanes flying through the sky.<|im_end|>
    
  • SFT数据格式(chatml格式)

    <|im_start|>system
    Follow the user's instruction and answer questions.<|im_end|>
    <|im_start|>user
    <Image><image></lmage>
    What activity are the people engaged in on the green field?<|im_end|>
    <|im_start|>assistant
    The people are engaged in playing a game of frisbee on the lush green field.<|im_end|>
    <|im_start|>user
    Is there a person wearing a fairy outfit in the image? If so, what are they doing?<|im_end|>
    <|im_start|>assistant
    Yes, there is a person wearing a fairy outfit in the image. They are walking in the field, likely
    participating in the fun activities along with the other people.<|im_end|>
    <|im_start|>user
    What can you say about the spectator's location in relation to the houses?<|im_end|>
    <|im_start|>assistant
    The spectators are watching a match being played in a location close to the houses, possibly indicating that the field is within a residential area or park.<|im_end|>
    
动态高分辨率

在数据处理阶段,采用动态高分辨率(DHR)方法来处理不同分辨率的图像输入。具体的如下图,图像被分割成最多6个瓦片(tile):

上述两张图都是动态DHR的处理过程,围绕图像的预处理,包括归一化、缩放、裁剪、根据宽高比动态处理等操作,构建了一套完整的流程,代码逻辑如下:

import torch
from PIL import Image
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode

IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)


def build_transform(input_size):
    MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
    transform = T.Compose([
        T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB'else img),
        T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
        T.ToTensor(),
        T.Normalize(mean=MEAN, std=STD)
    ])
    return transform


def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
    best_ratio_diff = float('inf')
    best_ratio = (1, 1)
    area = width * height
    for ratio in target_ratios:
        target_aspect_ratio = ratio[0] / ratio[1]
        ratio_diff = abs(aspect_ratio - target_aspect_ratio)
        if ratio_diff < best_ratio_diff:
            best_ratio_diff = ratio_diff
            best_ratio = ratio
        elif ratio_diff == best_ratio_diff:
            if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
                best_ratio = ratio
    return best_ratio


def dynamic_preprocess(image, min_num=1, max_num=6, image_size=448, use_thumbnail=True):
    orig_width, orig_height = image.size
    aspect_ratio = orig_width / orig_height

    target_ratios = set(
        (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
        i * j <= max_num and i * j >= min_num)
    target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])

    target_aspect_ratio = find_closest_aspect_ratio(
        aspect_ratio, target_ratios, orig_width, orig_height, image_size)

    target_width = image_size * target_aspect_ratio[0]
    target_height = image_size * target_aspect_ratio[1]
    blocks = target_aspect_ratio[0] * target_aspect_ratio[1]

    resized_img = image.resize((target_width, target_height))
    processed_images = []
    for i in range(blocks):
        box = (
            (i % (target_width // image_size)) * image_size,
            (i // (target_width // image_size)) * image_size,
            ((i % (target_width // image_size)) + 1) * image_size,
            ((i // (target_width // image_size)) + 1) * image_size
        )
        split_img = resized_img.crop(box)
        processed_images.append(split_img)
    assert len(processed_images) == blocks
    if use_thumbnail and len(processed_images) != 1:
        thumbnail_img = image.resize((image_size, image_size))
        processed_images.append(thumbnail_img)
    return processed_images


def load_image(image_file, input_size=448, max_num=6):
    image = Image.open(image_file).convert('RGB')
    transform = build_transform(input_size=input_size)
    images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
    pixel_values = [transform(image) for image in images]
    pixel_values = torch.stack(pixel_values)
    return pixel_values

loss效果

  • 预训练loss

    预训练loss,epoch=1

  • SFT loss

    SFT loss,epoch=1

训练配置

为了与llava1.5-13B公平对比,笔者在训练数据上和一些训练参数上进行了对齐。

  • pretrain阶段:冻结视觉侧和LLM侧,只训练MLP对齐,max-len=2048,gradient_accumulation_steps=4,单卡batch-size=8,8xH100,所有batch-size=8x4x8=256。

  • SFT阶段:继续保持视觉侧冻结,放开LLM,与MLP一起训练,max-len=2048,gradient_accumulation_steps=2,单卡batch-size=8,8xH100,所有batch-size=8x2x8=128。

推理


import torch
from modelscope import AutoTokenizer, AutoModel
from PIL import Image
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode

IMAGENET_MEAN = (0.485, 0.456, 0.406)
IMAGENET_STD = (0.229, 0.224, 0.225)


def build_transform(input_size):
    MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
    transform = T.Compose([
        T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
        T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
        T.ToTensor(),
        T.Normalize(mean=MEAN, std=STD)
    ])
    return transform


def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size):
    best_ratio_diff = float('inf')
    best_ratio = (1, 1)
    area = width * height
    for ratio in target_ratios:
        target_aspect_ratio = ratio[0] / ratio[1]
        ratio_diff = abs(aspect_ratio - target_aspect_ratio)
        if ratio_diff < best_ratio_diff:
            best_ratio_diff = ratio_diff
            best_ratio = ratio
        elif ratio_diff == best_ratio_diff:
            if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
                best_ratio = ratio
    return best_ratio


def dynamic_preprocess(image, min_num=1, max_num=12, image_size=448, use_thumbnail=False):
    orig_width, orig_height = image.size
    aspect_ratio = orig_width / orig_height

    # calculate the existing image aspect ratio
    target_ratios = set(
        (i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
        i * j <= max_num and i * j >= min_num)
    target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])

    # find the closest aspect ratio to the target
    target_aspect_ratio = find_closest_aspect_ratio(
        aspect_ratio, target_ratios, orig_width, orig_height, image_size)

    # calculate the target width and height
    target_width = image_size * target_aspect_ratio[0]
    target_height = image_size * target_aspect_ratio[1]
    blocks = target_aspect_ratio[0] * target_aspect_ratio[1]

    # resize the image
    resized_img = image.resize((target_width, target_height))
    processed_images = []
    for i in range(blocks):
        box = (
            (i % (target_width // image_size)) * image_size,
            (i // (target_width // image_size)) * image_size,
            ((i % (target_width // image_size)) + 1) * image_size,
            ((i // (target_width // image_size)) + 1) * image_size
        )
        # split the image
        split_img = resized_img.crop(box)
        processed_images.append(split_img)
    assert len(processed_images) == blocks
    if use_thumbnail and len(processed_images) != 1:
        thumbnail_img = image.resize((image_size, image_size))
        processed_images.append(thumbnail_img)
    return processed_images


def load_image(image_file, input_size=448, max_num=12):
    image = Image.open(image_file).convert('RGB')
    transform = build_transform(input_size=input_size)
    images = dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
    pixel_values = [transform(image) for image in images]
    pixel_values = torch.stack(pixel_values)
    return pixel_values


def preprocess_image(file_path, dynamic=True, max_num=6, image_size=448):
    try:
        if dynamic:
            return load_image(file_path, max_num=max_num).to(torch.bfloat16).cuda()
        else:
            img = Image.open(file_path).convert('RGB')
            transform = build_transform(image_size)
            pixel_values = transform(img)
            return torch.stack([pixel_values]).to(torch.bfloat16).cuda()
    except Exception as e:
        raise RuntimeError(f"Error processing image: {e}")


path = "Reyes-8B"

model = AutoModel.from_pretrained(
    path,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
).eval().cuda()

# print(model)

tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
generation_config = dict(max_new_tokens=2048, do_sample=False)

# single-image single-round conversation
file_path = 'tmp.png'
pixel_values = preprocess_image(file_path, dynamic=True)
question = '<image>\nPlease describe the image shortly.'
response = model.chat(tokenizer, pixel_values, question, generation_config)
print(f'User: {question}\nAssistant: {response}')

# pure-text conversation
question = 'Hello, who are you?'
response, history = model.chat(tokenizer, None, question, generation_config, history=None, return_history=True)
print(f'User: {question}\nAssistant: {response}')

评测

  1. MMMU评测(MMMU: A Massive Multi-discipline Multimodal Understanding and Reasoning Benchmark for Expert AGI)

    简介:MMMU 是一种新的基准,旨在评估多模态模型在需要大学水平的学科知识和深思熟虑的推理的大规模多学科任务中的表现。MMMU 包含11.5K 个精心收集的来自大学考试、测验和教科书的多模态问题,涵盖六个核心学科:艺术与设计、商业、科学、健康与医学、人文与社会科学以及技术与工程。这些问题涵盖30 个学科和183 个子领域,包含32 种高度异构的图像类型,如图表、图解、地图、表格、乐谱和化学结构。与现有基准不同,MMMU 专注于使用领域特定知识进行高级感知和推理,挑战模型执行类似于专家面临的任务。

    **评测结果显示:Reyes-8b比llava1.5-13b取得了更先进的结果。**详细评分如下:

  • llava1.5-13b得分:0.367

  • Reyes-8b得分:0.447

  1. 一些测试case
  • case1

    问题: Who painted <image 1>?
    选项: {'A':'Claude Monet', 'B':'Henri Matisse', 'C':'Andy Warhol','D': "Georgia O'Keefe"]
    预测的答案: C
    正确的答案: C
    
  • case2

    问题: Each situation below relates to an independent company's Owners' Equity. <image 1> Calculate the missing values of company 2.
    选项: {'A': '$1,620', 'B': '$12,000', 'C': '$51,180', 'D': '$0'}
    预测的答案: D
    正确的答案: D
    
  • case3

    问题: A survey line ABC crossing a river at right angles cut its banks at B and C, as shown in Fig. 2.39. To determine the width BC of the river, the following operation was carried out.A 60 m long line BE was set out roughly parallel to the river. Line CE was extended to D and mid-point F of DB was established. Then EF was extended to G such that FG = EF. Line DG was extended to cut the survey line ABC at H. GH and HB were measured and found to be 40 m and 80 m, respectively.Find the width of the river.<image 1>
    选项: {'A': '120 m', 'B': '122 m', 'C': '123 m', 'D': '121 m'}
    预测的答案: A
    正确的答案: A
    

总结

本文记录了从0到1实现一个多模态大模型的过程,包括模型结构、数据引擎、评测全流程。当前模型训练数据与llava1.5-13b对齐,并且在MMMU评测上以更小的模型参数量超越了llava1.5-13b,当前训练数据因为只采用了图文多模态数据,在SFT阶段,并未加入text-only数据,因此,语言模型端会出现一些退化。将来若有时间,会考虑加入更多的多模态数据及笔者私有数据进行训练(如:《【多模态 & 文档智能】一次多模态大模型表格识别解析探索小实践记录》),打造更强的Reyes模型。

内容概要:本文档《DeepSeek本地部署教程(非ollama)》详细介绍了DeepSeek大语言模型的本地部署流程。首先明确了环境要求,包括Python 3.8以上版本、CUDA 11.7(针对GPU用户)、至少16GB RAM以及推荐的操作系统。接着阐述了安装步骤,如克隆代码仓库、创建虚拟环境、安装依赖等。随后讲解了模型下载方式,支持从Hugging Face平台下载不同版本的DeepSeek模型,如DeepSeek-7B、DeepSeek-67B和DeepSeek-Coder。文档还提供了两种运行模型的方式:命令行运行和使用API服务。此外,针对常见的问题,如CUDA相关错误、内存不足和模型加载失败等,给出了详细的解决方案。最后,文档提出了性能优化建议,如使用量化技术减少内存占用、启用CUDA优化等,并强调了安全注意事项,包括定期更新模型和依赖包、注意API访问权限控制等方面。; 适合人群:对大语言模型感兴趣的研究人员、开发者,特别是希望在本地环境中部署和测试DeepSeek模型的技术人员。; 使用场景及目标:①帮助用户在本地环境中成功部署DeepSeek大语言模型;②解决部署过程中可能遇到的问题,如环境配置、模型下载和运行时的常见错误;③提供性能优化建议,确保模型在不同硬件条件下的最佳表现;④指导用户进行安全配置,保障模型和数据的安全性。; 阅读建议:在阅读本教程时,建议按照文档的步骤顺序逐步操作,同时结合实际情况调整环境配置和参数设置。对于遇到的问题,可以参考常见问题解决部分提供的解决方案。此外,性能优化部分的内容有助于提高模型的运行效率,值得深入研究。
Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目),该项目是个人大作业项目,答辩评审分达到98分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。 Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于SpringCloud架构的简易版个人网上银行系统源码(高分项目)Java基于S
内容概要:本文档详细介绍了基于JavaScript的俄罗斯方块游戏课程设计,旨在通过开发完整的俄罗斯方块游戏帮助学生掌握前端开发技术。课程设计分为课程背景与目标、项目意义、预期成果、需求分析、系统设计、详细设计、界面设计、实现方案、测试方案、项目进度安排以及总结与展望几个部分。系统设计采用模块化思想,包括游戏核心逻辑、界面渲染、用户交互和游戏状态管理四个主要模块。详细设计中定义了方块类、游戏类、渲染类和控制器类,明确了各组件的功能和交互方式。实现方案提供了HTML、CSS和JavaScript的具体代码示例,确保游戏在不同浏览器和设备上的兼容性。测试方案涵盖功能测试、边界测试、用户界面测试和兼容性测试,以保证游戏的质量。项目进度安排分为需求分析、编码实现、测试调试、文档编写和项目验收五个阶段,时间跨度约为11周。 适合人群:具备一定编程基础,特别是对JavaScript有一定了解的学生或初学者。 使用场景及目标:①巩固JavaScript基础知识,包括变量、函数、对象、数组、循环等;②理解并掌握DOM操作方法;③学习如何处理用户事件和实现交互效果;④掌握动画原理和实现方式;⑤培养解决实际问题的能力和逻辑思维。 其他说明:此课程设计不仅注重代码编写,还强调需求分析和方案设计,建议学习者在实践中结合这些内容,调试代码并不断优化游戏体验。此外,文档还提出了未来的改进方向,如添加更多游戏模式、实现多人对战、增加音效和动画效果等。
Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码.zip,该项目是个人大作业项目,答辩评审分达到98分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。 Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子跳绳队人员管理系统源码Java实现的洛杉矶第三人民医院女子
内容概要:本文档详细介绍了《C#超市收银系统课程设计》的内容,旨在通过实现一个简单的超市收银系统,帮助学生掌握C#语言的基础编程技巧、面向对象编程、Windows窗体应用程序开发以及数据库操作等知识点。系统主要功能包括商品信息的录入、存储和管理,支持扫码(或手动输入)结账、计算总价与找零、生成购物小票,并实现数据的持久化存储。系统采用三层架构设计,分别为表示层、业务逻辑层和数据访问层,确保系统的模块化、健壮性和可扩展性。此外,文档还提供了详细的类设计、数据库设计、源代码实现及系统测试用例,并总结了设计成果、遇到的问题及解决方案。 适合人群:计算机专业学生或具备一定C#编程基础的开发者,特别是对Windows窗体应用程序开发和数据库操作感兴趣的初学者。 使用场景及目标:① 学习C#语言的基本语法和面向对象编程;② 掌握Windows窗体应用程序的开发流程;③ 理解并实现数据库操作,如SQLite的使用;④ 提高程序设计和调试能力,增强对实际项目开发的理解。 其他说明:文档不仅提供了理论知识,还结合了实际操作,通过具体的功能实现和测试用例,帮助读者更好地理解和掌握C#编程技巧。此外,文档还提出了改进方向,如增加图形界面、会员管理、销售统计和报表功能等,鼓励读者进一步探索和完善系统。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值