Skip to content

Commit

Permalink
fix(api): trim model names relative to model path
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 17, 2023
1 parent 23a9d5a commit 4472a6f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions api/onnx_web/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,26 @@ def check_paths(context: ServerContext):
makedirs(context.output_path)


def get_model_name(model: str) -> str:
base = path.basename(model)
(file, _ext) = path.splitext(base)
return file


def load_models(context: ServerContext):
global diffusion_models
global correction_models
global upscaling_models

diffusion_models = glob(path.join(context.model_path, 'diffusion-*'))
diffusion_models.extend(glob(path.join(context.model_path, 'stable-diffusion-*')))

correction_models = glob(path.join(context.model_path, 'correction-*'))
upscaling_models = glob(path.join(context.model_path, 'upscaling-*'))
diffusion_models = [get_model_name(f) for f in glob(
path.join(context.model_path, 'diffusion-*'))]
diffusion_models.extend([
get_model_name(f) for f in glob(path.join(context.model_path, 'stable-diffusion-*'))])

correction_models = [
get_model_name(f) for f in glob(path.join(context.model_path, 'correction-*'))]
upscaling_models = [
get_model_name(f) for f in glob(path.join(context.model_path, 'upscaling-*'))]


def load_params(context: ServerContext):
Expand Down

0 comments on commit 4472a6f

Please sign in to comment.