Coder Social home page Coder Social logo

beauty.torch's Introduction

Double Decoder Consistency Audio Samples

This page accompanies this blog post

beauty.torch's People

Contributors

erogol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beauty.torch's Issues

criterion

Hi,
I cannot trace the code to find out what kind of criterion you have employed for training phase.
To be more specific, I am trying to finetune your model on my own data, However I'm encountering the following error, which is related to criterion part:

/home/amir/torch/install/share/lua/5.1/nn/THNN.lua:110: bad argument #2 to 'v' (mismatch between the batch size of input (1) and that of target (2) at /tmp/luarocks_cunn-scm-1-7242/cunn/lib/THCUNN/generic/ClassNLLCriterion.cu:41)

I checked the size of input and target they are the same.

Thank you in advance.

I have met the error "module 'models/init' not found"

Hi, @erogol

I have met the error "module 'models/init' not found"

My error message here:

module 'models/init' not found:No LuaRocks module found for models/initmodule 'models/init' not found:No LuaRocks module found for models/init

OS: Ubuntu14.04
Torch7

_pickle.UnpicklingError: invalid load key

model_best.t7

---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
<ipython-input-2-7e4eb97b904e> in <module>()
      2 fdet = AlignDlib()
      3 # define scoring model
----> 4 net = HotOrNotTorchRegression(gpu_mode=1,model_path='trained/', model_file='model_best.t7', image_size=224)

~/doc/beauty.torch/utils/Classifier.py in __init__(self, gpu_mode, model_path, model_file, image_size, mean, std)
    162     """
    163     def __init__(self, gpu_mode, model_path, model_file, image_size=224, mean=None, std=None):
--> 164         super(HotOrNotTorchRegression, self).__init__(gpu_mode, model_path=model_path, model_file=model_file, image_size=image_size, mean=mean, std=std, classification=False)
    165 
    166     def classify_image(self, img, N=10):

~/doc/beauty.torch/utils/Classifier.py in __init__(self, gpu_mode, model_path, model_file, image_size, mean, std, classification)
     81         else:
     82             model_path = os.path.join(ROOT_PATH, model_file)
---> 83         self.model = torch.load(model_path)
     84 
     85         if self.classification:

/usr/local/lib/python3.5/dist-packages/torch/serialization.py in load(f, map_location, pickle_module)
    229         f = open(f, 'rb')
    230     try:
--> 231         return _load(f, map_location, pickle_module)
    232     finally:
    233         if new_fd:

/usr/local/lib/python3.5/dist-packages/torch/serialization.py in _load(f, map_location, pickle_module)
    367 
    368     f.seek(0)
--> 369     magic_number = pickle_module.load(f)
    370     if magic_number != MAGIC_NUMBER:
    371         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '�'.

How that might be a problem?

Fails in CUDA

Finally I've managed to install all prerequisites (cunn, CUDA, cutorch)
Now I try to run an example as in your notebook:

import lutorpy as lua
import numpy as np
from skimage import io
from utils.img_processing import process_img
from utils.face_dlib import AlignDlib
from utils.Classifier import HotOrNotTorchRegression

# define face model
fdet = AlignDlib()
# define scoring model
net = HotOrNotTorchRegression(gpu_mode=0,model_path='trained/', model_file='model_best.t7', image_size=224)

# score function
def score_image(img):
    # find all faces
    dets = fdet.getAllFaceBoundingBoxes(img)
    # if there is only one match, go and score
    if len(dets) != 0:
        det = dets[0]
        img2, face_img = process_img(img, fdet, size=224, is_shortest=True,
                                    margins={'width':0.5, "bottom":0.5, "top":0.5},
                                    bbox={'x1':int(np.round(det.left())),
                                           'x2':int(np.round(det.right())),
                                           'y1':int(np.round(det.top())),
                                           'y2':int(np.round(det.bottom()))})
        score =  net.classify_image(img2)[1]
        return img2, score
    else:
        return None, None

# read an example image from web
img_url = "https://s-media-cache-ak0.pinimg.com/originals/9a/3b/65/9a3b65c368c712ca322394ee4d19d407.jpg"
img = io.imread(img_url)
score = score_image(img)[1]

Output:

THCudaCheck FAIL file=/home/serj/torch/extra/cutorch/lib/THC/THCGeneral.c line=66 error=30 : unknown error
Traceback (most recent call last):
  File "example.py", line 6, in <module>
    from utils.Classifier import HotOrNotTorchRegression
  File "/home/serj/work/beautytorch/beauty.torch/utils/Classifier.py", line 11, in <module>
    lua.require('cunn')
  File "/home/serj/work/beautytorch/venv/local/lib/python2.7/site-packages/lutorpy/__init__.py", line 112, in require
    ret = luaRuntime.require(module_name)
  File "lutorpy/_lupa.pyx", line 318, in lutorpy._lupa.LuaRuntime.require (lutorpy/_lupa.c:6189)
  File "lutorpy/_lupa.pyx", line 1658, in lutorpy._lupa.call_lua (lutorpy/_lupa.c:25877)
  File "lutorpy/_lupa.pyx", line 1667, in lutorpy._lupa.execute_lua_call (lutorpy/_lupa.c:25987)
  File "lutorpy/_lupa.pyx", line 1620, in lutorpy._lupa.raise_lua_error (lutorpy/_lupa.c:25297)
lutorpy._lupa.LuaError: cuda runtime error (30) : unknown error at /home/serj/torch/extra/cutorch/lib/THC/THCGeneral.c:66

Maybe the problem is that my GPU is not NVidia. Can I disable cunn somehow? Please help!

ADD: can't run convert2cpu because of the same.

UPD As adviced by cutorch developers the conversion from GPU to CPU model is not possible without having NVidia GPU. It would be very helpful if CPU model could be shared as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.