GithubHelp home page GithubHelp logo

Comments (4)

Li-rr avatar Li-rr commented on June 30, 2024

Hi, I got same problem with you, do you solve it?

from im2avatar.

uree avatar uree commented on June 30, 2024

I solved it by making the code tensorflow 2.x compatible. I had trouble making earlier versions/docker images of tf work so this was the reasonable thing to do from my perspective. I used the latest tf docker image with gpu support.

First of you can use this tool to convert the code and it will then tell you what else you need to clean up. One such thing is to replace the _global_parser with argparse, which mostly means you need to rewrite the flags like this (from train_shape.py):

# tf.app.flags.DEFINE_string('train_dir', './train_shape',
#                            """Directory where to write summaries and checkpoint.""")
parser.add_argument('--train_dir', default='./train_shape', help= """Directory where to write summaries and checkpoint.""")

# tf.app.flags.DEFINE_string('base_dir', './data/ShapeNetCore_im2avatar',
#                            """The path containing all the samples.""")
parser.add_argument('--base_dir', default='./data/ShapeNetCore_im2avatar', help="""The path containing all the samples.""")

# tf.app.flags.DEFINE_string('cat_id', '02958343',
#                            """The category id for each category: 02958343, 03001627, 03467517, 04379243""")
parser.add_argument('--cat_id', default='02958343', help= """The category id for each category: 02958343, 03001627, 03467517, 04379243""")

# tf.app.flags.DEFINE_string('data_list_path', './data_list',
#                           """The path containing data lists.""")
parser.add_argument('--data_list_path', default='./data_list', help= """The path containing data lists.""")


# tf.app.flags.DEFINE_integer('train_epochs', 501, """Training epochs.""")
parser.add_argument('--train_epochs', default=501, help= """The path containing data lists.""", type=int)

# tf.app.flags.DEFINE_integer('batch_size', 60, """Batch size.""")
parser.add_argument('--batch_size', default=30, help= """Batch size.""", type=int)

# tf.app.flags.DEFINE_integer('gpu', 0, """""")
parser.add_argument('--gpu', default=0, help= """""", type=int)

# tf.app.flags.DEFINE_float('learning_rate', 0.0003, """""")
parser.add_argument('--learning_rate', default=0.0003, help= """""", type=float)

# tf.app.flags.DEFINE_float('wd', 0.00001, """""")
parser.add_argument('--wd', default=0.00001, help= """""", type=float)

# tf.app.flags.DEFINE_integer('epochs_to_save',20, """""")
parser.add_argument('--epochs_to_save', default=20, help="""""", type=int)

# tf.app.flags.DEFINE_integer('decay_step',20000, """for lr""")
parser.add_argument('--decay_step', default=2000, help="""for lr""", type=int)

# tf.app.flags.DEFINE_float('decay_rate', 0.7, """for lr""")
parser.add_argument('--decay_rate', default=0.7, help="""for lr""", type=int)

and replace all other occurrences of flags, so that the code uses values from parser/argparse.

The other issue I had to solve was to avoid using xavier_initializer (deprecated to). Presumably can just comment it out and go with the truncated_normal_initializer here. People have suggested using GlorotUniform() too.

I'll share the code once I'm sure I can get the rest of it to work too (inference ...)

from im2avatar.

YakamiNad avatar YakamiNad commented on June 30, 2024

I solved it by making the code tensorflow 2.x compatible. I had trouble making earlier versions/docker images of tf work so this was the reasonable thing to do from my perspective. I used the latest tf docker image with gpu support.

First of you can use this tool to convert the code and it will then tell you what else you need to clean up. One such thing is to replace the _global_parser with argparse, which mostly means you need to rewrite the flags like this (from train_shape.py):

# tf.app.flags.DEFINE_string('train_dir', './train_shape',
#                            """Directory where to write summaries and checkpoint.""")
parser.add_argument('--train_dir', default='./train_shape', help= """Directory where to write summaries and checkpoint.""")

# tf.app.flags.DEFINE_string('base_dir', './data/ShapeNetCore_im2avatar',
#                            """The path containing all the samples.""")
parser.add_argument('--base_dir', default='./data/ShapeNetCore_im2avatar', help="""The path containing all the samples.""")

# tf.app.flags.DEFINE_string('cat_id', '02958343',
#                            """The category id for each category: 02958343, 03001627, 03467517, 04379243""")
parser.add_argument('--cat_id', default='02958343', help= """The category id for each category: 02958343, 03001627, 03467517, 04379243""")

# tf.app.flags.DEFINE_string('data_list_path', './data_list',
#                           """The path containing data lists.""")
parser.add_argument('--data_list_path', default='./data_list', help= """The path containing data lists.""")


# tf.app.flags.DEFINE_integer('train_epochs', 501, """Training epochs.""")
parser.add_argument('--train_epochs', default=501, help= """The path containing data lists.""", type=int)

# tf.app.flags.DEFINE_integer('batch_size', 60, """Batch size.""")
parser.add_argument('--batch_size', default=30, help= """Batch size.""", type=int)

# tf.app.flags.DEFINE_integer('gpu', 0, """""")
parser.add_argument('--gpu', default=0, help= """""", type=int)

# tf.app.flags.DEFINE_float('learning_rate', 0.0003, """""")
parser.add_argument('--learning_rate', default=0.0003, help= """""", type=float)

# tf.app.flags.DEFINE_float('wd', 0.00001, """""")
parser.add_argument('--wd', default=0.00001, help= """""", type=float)

# tf.app.flags.DEFINE_integer('epochs_to_save',20, """""")
parser.add_argument('--epochs_to_save', default=20, help="""""", type=int)

# tf.app.flags.DEFINE_integer('decay_step',20000, """for lr""")
parser.add_argument('--decay_step', default=2000, help="""for lr""", type=int)

# tf.app.flags.DEFINE_float('decay_rate', 0.7, """for lr""")
parser.add_argument('--decay_rate', default=0.7, help="""for lr""", type=int)

and replace all other occurrences of flags, so that the code uses values from parser/argparse.

The other issue I had to solve was to avoid using xavier_initializer (deprecated to). Presumably can just comment it out and go with the truncated_normal_initializer here. People have suggested using GlorotUniform() too.

I'll share the code once I'm sure I can get the rest of it to work too (inference ...)

Hi did you solve the issue as i have quite a few bugs when compiling, much thanks!

from im2avatar.

uree avatar uree commented on June 30, 2024

What a coincidence. I uploaded an adapted version of the code which worked for me just now. It might help you ... https://github.com/uree/im2avatar-debian

from im2avatar.

Related Issues (11)

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.