Skip to content

Commit

Permalink
fix spawning powershell need hide window
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberhan123 committed Jan 11, 2024
1 parent cd5b9c0 commit 35778a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions embed_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"log"
"os/exec"
"strings"
"syscall"

"golang.org/x/sys/cpu"
)
Expand Down Expand Up @@ -102,6 +103,12 @@ func NewGPU() (*GPU, error) {
$graphicsArray | ConvertTo-Json
`)

cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: true,
//https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
CreationFlags: 0x08000000,
}

output, err := cmd.CombinedOutput()
if err != nil {
return nil, err
Expand Down
9 changes: 9 additions & 0 deletions sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,17 @@ func (sd *Model) ImagePredict(reader io.Reader, prompt string, params FullParams

func (sd *Model) UpscaleImage(reader io.Reader, esrganPath string, upscaleFactor uint32, writer io.Writer) error {
if sd.upscalerCtx == nil {
sd.esrganPath = esrganPath
sd.upscalerCtx = sd.csd.NewUpscalerCtx(esrganPath, sd.options.Threads, sd.options.Wtype)
}

if sd.esrganPath != esrganPath {
if sd.upscalerCtx != nil {
sd.csd.FreeUpscalerCtx(sd.upscalerCtx)
}
sd.upscalerCtx = sd.csd.NewUpscalerCtx(esrganPath, sd.options.Threads, sd.options.Wtype)
}

decode, _, err := image.Decode(reader)
if err != nil {
return err
Expand Down

0 comments on commit 35778a4

Please sign in to comment.