Skip to content

Commit

Permalink
Remove free calls from imageGeneration.generate
Browse files Browse the repository at this point in the history
we resort to just restarting the last used backend.
The additional free calls are no longer required.
  • Loading branch information
florianesser-tng committed Dec 17, 2024
1 parent 1380feb commit fa6cc1c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 41 deletions.
19 changes: 0 additions & 19 deletions WebUI/src/assets/js/store/comfyUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,28 +288,9 @@ export const useComfyUi = defineStore("comfyUi", () => {
})
}

async function free() {
if (!isComfyRunning) {
console.debug('ComfyUI backend not running, nothing to free');
return;
}
await fetch(`${comfyBaseUrl.value}/free`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ free_memory: true,
unload_models: true })
})
await fetch(`${useGlobalSetup().apiHost}/api/triggerxpucacheclear`, {
method: "POST"
})
}

return {
generate,
stop,
free,
}
}, {
persist: {
Expand Down
2 changes: 0 additions & 2 deletions WebUI/src/assets/js/store/imageGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,8 @@ export const useImageGeneration = defineStore("imageGeneration", () => {
previewIdx.value = 0;
stepText.value = i18nState.COM_GENERATING;
if (activeWorkflow.value.backend === 'default') {
comfyUi.free();
stableDiffusion.generate();
} else {
stableDiffusion.free();
comfyUi.generate();
}
}
Expand Down
8 changes: 1 addition & 7 deletions WebUI/src/assets/js/store/stableDiffusion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,12 @@ export const useStableDiffusion = defineStore("stableDiffusion", () => {
}
}

async function free() {
await fetch(`${useGlobalSetup().apiHost}/api/free`, {
method: "POST"
})
}

return {
generateParams,
generate,
stop,
free,
}

}, {
persist: {
pick: ['settings', 'hdWarningDismissed']
Expand Down
13 changes: 0 additions & 13 deletions service/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ def llm_chat():
return Response(stream_with_context(it), content_type="text/event-stream")


@app.post("/api/triggerxpucacheclear")
def trigger_xpu_cache_clear():
paint_biz.clear_xpu_cache()
return Response("{'message':'triggered xpu cache clearance'}", status=201, mimetype='application/json')


@app.post("/api/free")
def free():
paint_biz.dispose()
import llm_biz
llm_biz.dispose()
return jsonify({"code": 0, "message": "success"})

@app.get("/api/llm/stopGenerate")
def stop_llm_generate():
import llm_biz
Expand Down

0 comments on commit fa6cc1c

Please sign in to comment.