Skip to content

/usr/lib/python3.7/site-packages/torch/jit/_trace.py:754: UserWarning: The input to trace is already a ScriptModule, tracing it is a no-op. Returning the object as is. #3

@claire199705

Description

@claire199705

import torch
from PIL import Image

img = Image.open('hen.jpg')
model = torch.hub.load('hankyul2/EfficientNetV2-pytorch', 'efficientnet_v2_s', pretrained=True, nclass=1000)

import matplotlib.pyplot as plt
from torchvision import transforms

transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
x = transform(img).unsqueeze(0)
model.eval()
trace_model = torch.jit.trace(model, x)
torch.jit.trace(trace_model, "./efficientnet_v2_s.pt")
print("Successfully save traced model")

torch jit trace出现问题

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions