如何修复此错误:需要以下参数:inpath、outpath

2024-04-18 23:09:12 发布

您现在位置:Python中文网/ 问答频道 /正文

这是错误消息

Hassans-MacBook-Pro-3:fast-style-transfer-master hassan$ python3 evaluate.py --checkpoint ./rain-princess.ckpt --in-path/Users/hassan/Downloads/fast-style-transfer-master--out-path ./output_image.jpg
usage: evaluate.py [-h] --checkpoint CHECKPOINT --in-path IN_PATH --out-path
                   OUT_PATH [--device DEVICE] [--batch-size BATCH_SIZE]
                   [--allow-different-dimensions]
evaluate.py: error: the following arguments are required: --in-path, --out-path

这是evaluate.py脚本的一部分,我只是在遵循一个教程,文件放置不正确

from __future__ import print_function
import sys
sys.path.insert(0, 'src')
import transform, numpy as np, vgg, pdb, os
import scipy.misc
import tensorflow as tf
from utils import save_img, get_img, exists, list_files
from argparse import ArgumentParser
from collections import defaultdict
import time
import json
import subprocess
import numpy
from moviepy.video.io.VideoFileClip import VideoFileClip
import moviepy.video.io.ffmpeg_writer as ffmpeg_writer

BATCH_SIZE = 4
DEVICE = '/gpu:0'


def ffwd_video(path_in, path_out, checkpoint_dir, device_t='/gpu:0', batch_size=4):
    video_clip = VideoFileClip(path_in, audio=False)
    video_writer = ffmpeg_writer.FFMPEG_VideoWriter(path_out, video_clip.size, video_clip.fps, codec="libx264",
                                                    preset="medium", bitrate="2000k",
                                                    audiofile=path_in, threads=None,
                                                    ffmpeg_params=None)

    g = tf.Graph()
    soft_config = tf.compat.v1.ConfigProto(allow_soft_placement=True)
    soft_config.gpu_options.allow_growth = True
    with g.as_default(), g.device(device_t), \
            tf.compat.v1.Session(config=soft_config) as sess:
        batch_shape = (batch_size, video_clip.size[1], video_clip.size[0], 3)
        img_placeholder = tf.compat.v1.placeholder(tf.float32, shape=batch_shape,
                                         name='img_placeholder')

        preds = transform.net(img_placeholder)
        saver = tf.compat.v1.train.Saver()
        if os.path.isdir(checkpoint_dir):
            ckpt = tf.train.get_checkpoint_state(checkpoint_dir)
            if ckpt and ckpt.model_checkpoint_path:
                saver.restore(sess, ckpt.model_checkpoint_path)
            else:
                raise Exception("No checkpoint found...")
        else:
            saver.restore(sess, checkpoint_dir)

非常感谢你愿意帮忙 非常感谢你愿意帮忙 非常感谢你愿意帮忙


Tags: pathinfromimportimgsizecliptf
1条回答
网友
1楼 · 发布于 2024-04-18 23:09:12

这个错误来自程序evaluate.py本身,这显然是您编写或下载的东西,因此我们无法在不看到它的情况下回答。然而,仅从错误消息来看

the following arguments are required:  in-path,  out-path

我注意到在您的命令行中

python3 evaluate.py  checkpoint ./rain-princess.ckpt  in-path/Users/hassan/Downloads/fast-style-transfer-master out-path ./output_image.jpg

这两个文件都没有,因为 in-path和它的参数之间没有空格,这个文件名和 out-path之间也没有空格。所以我试着把这个改成

python3 evaluate.py  checkpoint ./rain-princess.ckpt  in-path /Users/hassan/Downloads/fast-style-transfer-master  out-path ./output_image.jpg

看看这是否能推动事情的发展

如果这不能解决问题,我们将需要一些关于evaluate.py是什么的上下文

相关问题 更多 >