You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This uses straight Python by modifying sys.argv before calling generate.py, this seems over convoluted to pass args:
import sys
import argparse
import imp
vqgan_generate_dir = "/foo/baa/"
def generate( prompts ):
vq_parser = argparse.ArgumentParser(description='Process some params.')
vq_parser.add_argument("-p", "--prompts", type=str, help="Text prompts", default=None, dest='prompts')
sys.argv = ['generate.py'] # define your commandline arguments here
if prompts:
sys.argv.append("-p")
sys.argv.append(prompts)
args = vq_parser.parse_args()
print (args)
############################################################################
#Load & run the generate.py module
############################################################################
try:
fp, pathname, description = imp.find_module('generate', vqgan_generate_path)
generate = imp.load_module("generate", fp, pathname, description)
except ImportError:
print(f"Could not import: {vqgan_generate_dir}generate.py")
quit()
finally:
if fp:
fp.close()
neither of these are tested yet as I'm just exploring concepts, what do you think is the best way? is there another way?
option two gets really long-winded once you want ALL args, and option one is overly simplistic and doesn't allow you to control the params going in well.
The text was updated successfully, but these errors were encountered:
I want to call generate.py from my python application, what is the "best" way to do this? i currently have two options:
This uses the shell to run another process, not ideal as I would like to stay in python, but its easy...
This uses straight Python by modifying sys.argv before calling generate.py, this seems over convoluted to pass args:
neither of these are tested yet as I'm just exploring concepts, what do you think is the best way? is there another way?
option two gets really long-winded once you want ALL args, and option one is overly simplistic and doesn't allow you to control the params going in well.
The text was updated successfully, but these errors were encountered: