other-app / gradify.py
lint's picture
Upload folder using huggingface_hub
29046a4
def gradify_closure(func, argmaps, func_kwargs={}):
func_kwargs = dict(func_kwargs)
def gradify_func(*args):
kwargs = {}
for (arg, argmap) in zip(args, argmaps):
postprocessing = argmap.get("postprocessing", None)
if postprocessing:
arg = eval(postprocessing)(arg)
kw_label = argmap["label"]
kwargs[kw_label] = arg
return func(**kwargs, **func_kwargs)
return gradify_func
def compile_callable(source, target_name=None):
ldict = {}
exec(source, globals(), ldict)
if target_name:
return ldict[target_name]
else:
for v in ldict.values():
if callable(v):
return v