-
Notifications
You must be signed in to change notification settings - Fork 2
fix: wire -s/-z scale flags and fix format flag handling #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||
| package main | ||||
|
|
||||
| import ( | ||||
| "fmt" | ||||
| "github.com/spf13/cobra" | ||||
| "github.com/yashschandra/upscayl-cli/upscayl" | ||||
| "log" | ||||
|
|
@@ -15,11 +16,33 @@ func getRunCommand() *cobra.Command { | |||
| url, _ := cmd.Flags().GetString("url") | ||||
| model, _ := cmd.Flags().GetString("model-name") | ||||
| outputPath, _ := cmd.Flags().GetString("output") | ||||
| outputScale, _ := cmd.Flags().GetInt("output-scale") | ||||
| compress, _ := cmd.Flags().GetInt("compress") | ||||
| tileSizeStr, _ := cmd.Flags().GetString("tile-size") | ||||
| modelPath, _ := cmd.Flags().GetString("model-path") | ||||
| format, _ := cmd.Flags().GetString("format") | ||||
| tta, _ := cmd.Flags().GetBool("tta") | ||||
|
|
||||
| scaleStr := fmt.Sprintf("%d", outputScale) | ||||
|
|
||||
| var tileSize *int | ||||
| if tileSizeStr != "0" { | ||||
| var t int | ||||
| fmt.Sscanf(tileSizeStr, "%d", &t) | ||||
| tileSize = &t | ||||
| } | ||||
|
|
||||
| input := upscayl.Input{ | ||||
| ImagePath: imagePath, | ||||
| ImageURL: url, | ||||
| Model: model, | ||||
| OutputPath: outputPath, | ||||
| ImagePath: imagePath, | ||||
| ImageURL: url, | ||||
| Model: model, | ||||
| OutputPath: outputPath, | ||||
| Scale: scaleStr, | ||||
| Compression: fmt.Sprintf("%d", compress), | ||||
| TileSize: tileSize, | ||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately for this (and other tile size related code) to work, we have to pass the value (not pointer) upscayl-cli/upscayl/upscayl.go Line 248 in c4397f6
|
||||
| ModelPath: modelPath, | ||||
| SaveImageAs: format, | ||||
| TTAMode: tta, | ||||
| } | ||||
| outputPath, err := upscayl.Upscayl(input) | ||||
| if err != nil { | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -226,10 +226,12 @@ func upscaylImage(input Input) (string, error) { | |||
| return "", errors.New("model does not exist") | ||||
| } | ||||
| args = append(args, fmt.Sprintf("-m %s", input.ModelPath)) | ||||
| if input.SaveImageAs == "" { | ||||
| if input.SaveImageAs == "" || input.SaveImageAs == "ext/png" { | ||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding a condition here, lets remove the default Line 45 in c4397f6
|
||||
| input.SaveImageAs = filepath.Ext(input.ImagePath)[1:] | ||||
| } | ||||
| args = append(args, fmt.Sprintf("-f %s", input.SaveImageAs)) | ||||
| if input.SaveImageAs != "" { | ||||
| args = append(args, fmt.Sprintf("-f %s", input.SaveImageAs)) | ||||
| } | ||||
| if input.GPUId != nil { | ||||
| args = append(args, fmt.Sprintf("-g %d", input.GPUId)) | ||||
| } | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can directly do
fmt.Sprintf("%d", outputScale)without defining a new variable to keep code slightly cleaner