首页 > 其他分享 >kaggle notebook 处理临时脚本的方法

kaggle notebook 处理临时脚本的方法

时间:2023-06-05 20:24:01浏览次数:47  
标签:脚本 parser -- image args kaggle notebook add train

#=写入项目临时代码
aaa='''
#!/usr/bin/env python
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#============这个脚本通过finetune instructpix2pix来得到更好的模型.

"""Script to fine-tune InstructPix2Pix."""

import argparse
import logging
import math
import os
from pathlib import Path
from typing import Optional

import accelerate
import datasets
import diffusers
import numpy as np
import PIL
import requests
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import ProjectConfiguration, set_seed
from datasets import load_dataset
from diffusers import (AutoencoderKL, DDPMScheduler,
                       StableDiffusionInstructPix2PixPipeline,
                       UNet2DConditionModel)
from diffusers.optimization import get_scheduler
from diffusers.training_utils import EMAModel
from diffusers.utils import check_min_version, deprecate, is_wandb_available
from diffusers.utils.import_utils import is_xformers_available
from huggingface_hub import HfFolder, Repository, create_repo, whoami
from packaging import version
from torchvision import transforms
from tqdm.auto import tqdm
from transformers import CLIPTextModel, CLIPTokenizer

# Will error if the minimal version of diffusers is not installed. Remove at your own risks.
check_min_version("0.15.0.dev0")

logger = get_logger(__name__, log_level="INFO")

DATASET_NAME_MAPPING = {
    "sayakpaul/cartoonizer-dataset": (
        "original_image",
        "edit_prompt",
        "cartoonized_image",
    ),
}
WANDB_TABLE_COL_NAMES = ["original_image", "edited_image", "edit_prompt"]


def parse_args():
    parser = argparse.ArgumentParser(
        description="Simple example of a training script for InstructPix2Pix."
    )
    parser.add_argument(
        "--pretrained_model_name_or_path",
        type=str,
        default=None,
        required=True,
        help="Path to pretrained model or model identifier from huggingface.co/models.",
    )
    parser.add_argument(
        "--revision",
        type=str,
        default=None,
        required=False,
        help="Revision of pretrained model identifier from huggingface.co/models.",
    )
    parser.add_argument(
        "--dataset_name",
        type=str,
        default=None,
        help=(
            "The name of the Dataset (from the HuggingFace hub) to train on (could be your own, possibly private,"
            " dataset). It can also be a path pointing to a local copy of a dataset in your filesystem,"
            " or to a folder containing files that 

标签:脚本,parser,--,image,args,kaggle,notebook,add,train
From: https://www.cnblogs.com/zhangbo2008/p/17458830.html

相关文章

  • PyInstaller 完美打包 Python 脚本,输出结构清晰、便于二次编辑的打包程序
    引入问题如果我要写一个Python项目,打包成exe运行(方便在没有Python的电脑上使用),我需要打包出的根目录结构美观,没有多余的、杂乱的依赖文件在那里碍眼,而且需要在发现bug时,我还需要能够修改里面的代码后,无需再次打包,就能正常运行,该怎么做呢?就以一个Hello项目为例,记一下我......
  • 使用定时任务+脚本方式对nginx进行日志切分
    使用定时任务+脚本方式对nginx进行日志切分nginx路径:/home/nf/nginxnginx日志路径:/home/nf/nginx/logs切分目标文件:access.logerror.log创建脚本: 1vim/home/nf/cut_nginx_log.sh 1#!/bin/bash2#nginxlogpath3LOGS_PATH=/home/nf/nginx/logs4YESTERDAY=$(d......
  • 传奇开服架设教程--GeeM2与GomM2引擎通用假人脚本
    开新区注意事项:1、新区无任何玩家数据下可以运行“MirServer\假人行会初始化”目录下的“点我初始化假人行会.Bat”程序2、默认假人后台管理密码为:www.idc02.com假人修改说明:市面上的版本千变万化,不可能统一全部数据,以下就是可以随版本修改的自定义假人假人等级,装备修改路径:“Mir......
  • mysql数据自动备份脚本
    #!/bin/bash#日期date=$(date'+%Y%m%d')#设置备份目录和保留天数backup_dir="/opt/dbback"retention_days=7#数据库账密muser=mpasswd=mhost=#创建备份目录(如果不存在)mkdir-p$backup_dir#获取当前时间戳now=$(date+%s)#备份MySQL数据库到备份目......
  • 基于Selenium库的python爬虫脚本,爬取painterest上的图片
    基于Selenium库的python爬虫脚本,爬取painterest上的图片问题背景Pinterest是一个社交媒体平台,它提供了一个虚拟的个人兴趣画板,让用户可以收集和分享他们喜欢的图片、视频和链接。上面有许多优秀的图片供浏览和下载,但是一个个点图片下载非常麻烦。于是想要用Python语言写一个自......
  • Ubuntu 创建开机自启动脚本的方法
    Ubuntu创建开机自启动脚本的步骤如下:1)将你的启动脚本复制到 /etc/init.d目录下以下假设你的脚本文件名为test。 2)设置脚本文件的权限$sudochmod755/etc/init.d/test 3)执行如下命令将脚本放到启动脚本中去:......
  • pnpm:无法加载文件 C:\Users\Five\AppData\Roaming\npm\pnpm.ps1 ,因为在此系统
    前言重装完了电脑系统,运行pnpm无法加载文件,pnpm-V也不行解决方案用管理员方式启动powershell输入命令:set-ExecutionPolicyRemoteSigned然后再输入:Y重启代码编辑器 ......
  • MAC为usr/local/bin添加新脚本
    方法一创建脚本文件,删除后缀名将脚本文件添加到/usr/local/bin/目录下使用sudochmod777/usr/local/bin/yourscriptname修改访问权限此时可以看见,文件显示为Unix可执行文件重启控制台即可使用方法二创建脚本文件,不需删除后缀使用sudoIn-s/yourpath/......
  • Godot的几个附加脚本和进行继承时比较特别的特性
    注:这是在Godot4.0中总结出的内容,并且语言是C#。特别的,下面有的特性和C#关系比较大。基本特性在Godot中,为某个节点编写特别的代码时,需要为节点新建脚本,或引用已有脚本。引用脚本时,填入脚本路径即可,相当于是复用代码了。新建脚本时,一般做法是新建一个自定义类型,并且......
  • 4、虚拟机单机、集群的克隆、删除脚本(以初始化好的虚拟机为模板)
    虚拟机克隆、删除脚本[root@ubunt~]#catclone.sh#!/bin/bash##./etc/init.d/functions(如果是ubuntu,注释此行)Red="\e[1;31m"Purple="\e[1;35m"Green="\e[1;32m"Blue="\e[1;36m"Yellow="\e[1;33m"End="\e[0m&......