安装了 Anaconda 却找不到 Anaconda prompt ?

做模型过程中的问题总结

anaconda prompt 找不到怎么解决?

anaconda prompt找不到解决方法:

第一步:win+R输入cmd进入命令行,进入到Anaconda的安装目录,语句:cd Anaconda的安装目录。例如我的:

cd D:\Anaconda3

第二步:进入到Anaconda的安装目录后,输入:

python .\Lib\_nsis.py mkmenus

第三步:打开电脑左下方的开始菜单,点击所有程序,就可以看到重新出现了的Anaconda3文件夹,点开里面有Prompt

import onnxruntime as ort
import numpy as np

# 载入模型
import torch
from torch.utils.data import DataLoader
from torchvision import transforms

from inference_utils import VideoReader, VideoWriter
import time


sess = ort.InferenceSession('rvm_mobilenetv3_fp32.onnx')

# 创建 io binding.
io = sess.io_binding()

# 在 CUDA 上创建张量
rec = [ ort.OrtValue.ortvalue_from_numpy(np.zeros([1, 1, 1, 1], dtype=np.float32), 'cpu') ] * 4
print(rec)
downsample_ratio = ort.OrtValue.ortvalue_from_numpy(np.asarray([0.25], dtype=np.float32), 'cpu')
# 设置输出项
for name in ['fgr', 'pha', 'r1o', 'r2o', 'r3o', 'r4o']:
    io.bind_output(name, 'cuda')

def to_numpy(tensor):
    return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()


reader = VideoReader('input/b5.mp4', transforms.ToTensor())
# writer_com = VideoWriter(
#         path='output/TEST_12/com.mp4',
#         frame_rate=30,
#         bit_rate=int(4 * 1000000))
writer_pha = VideoWriter(
        path='output/test/pha.mp4',
        frame_rate=30,
        bit_rate=int(4 * 1000000))
writer_fgr = VideoWriter(
        path='output/test/fgr.mp4',
        frame_rate=30,
        bit_rate=int(4 * 1000000))
# bgr = torch.tensor([255, 255, 255], device=device, dtype=dtype).div(255).view(1, 1, 3, 1, 1)

# 推断
try:

    start = time.clock() #推理计时开始
    for src in DataLoader(reader):
        # io.bind_input(name='input', device_type='cpu', device_id=0, element_type=np.float32,
        #                       shape=to_numpy(src).shape(), buffer_ptr=to_numpy(src).data_ptr())
        io.bind_cpu_input('src', to_numpy(src))
        io.bind_ortvalue_input('r1i', rec[0])
        io.bind_ortvalue_input('r2i', rec[1])
        io.bind_ortvalue_input('r3i', rec[2])
        io.bind_ortvalue_input('r4i', rec[3])
        io.bind_ortvalue_input('downsample_ratio', downsample_ratio)

        # print(type(io))
        sess.run_with_iobinding(io)

        fgr, pha, *rec = io.get_outputs()
        # print(type(fgr), type(pha), type(*rec))

        # com = fgr * pha + bgr * (1 - pha)
        # writer_com.write(com[0])


        # 只将 `fgr` 和 `pha` 回传到 CPU
        fgr = fgr.numpy()
        pha = pha.numpy()
        print(type(fgr), type(pha), fgr.shape)
        writer_fgr.write(torch.tensor(fgr))
        writer_pha.write(torch.tensor(pha))
    end = time.clock()  # 计时结束

finally:
    # Clean up
    writer_pha.close()
    writer_fgr.close()

安装了 Anaconda 却找不到 Anaconda prompt ?_第1张图片

你可能感兴趣的:(python)