Skip to content

Commit

Permalink
0.2.1 (#27)
Browse files Browse the repository at this point in the history
* Fix backend env var parsing

* 0.2.1

* Fix getting cpu mode
  • Loading branch information
joeyballentine authored Feb 11, 2022
1 parent 8533cf3 commit 5206c69
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
23 changes: 10 additions & 13 deletions backend/nodes/pytorch_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@

from .node_base import NodeBase
from .node_factory import NodeFactory
from .properties.inputs.file_inputs import DirectoryInput, PthFileInput, TorchFileInput
from .properties.inputs.file_inputs import (DirectoryInput, PthFileInput,
TorchFileInput)
from .properties.inputs.generic_inputs import SliderInput, TextInput
from .properties.inputs.numpy_inputs import ImageInput
from .properties.inputs.pytorch_inputs import (
ModelInput,
StateDictInput,
TorchScriptInput,
)
from .properties.inputs.pytorch_inputs import (ModelInput, StateDictInput,
TorchScriptInput)
from .properties.outputs.numpy_outputs import ImageOutput
from .properties.outputs.pytorch_outputs import (
ModelOutput,
StateDictOutput,
TorchScriptOutput,
)
from .properties.outputs.pytorch_outputs import (ModelOutput, StateDictOutput,
TorchScriptOutput)
from .utils.architecture.RRDB import RRDBNet as ESRGAN
from .utils.architecture.SPSR import SPSRNet as SPSR
from .utils.architecture.SRVGG import SRVGGNetCompact as RealESRGANv2
Expand All @@ -38,7 +33,9 @@ def check_env():
"cuda" if torch.cuda.is_available() and os.environ["device"] != "cpu" else "cpu"
)

if bool(os.environ["isFp16"]):
logger.info(f"Using device: {os.environ['device']}")

if os.environ["isFp16"] == "True":
if os.environ["device"] == "cpu":
torch.set_default_tensor_type(torch.HalfTensor)
elif os.environ["device"] == "cuda":
Expand Down Expand Up @@ -162,7 +159,7 @@ def run(self, model: torch.nn.Module, img: np.ndarray) -> np.ndarray:
# Borrowed from iNNfer
logger.info("Converting image to tensor")
img_tensor = np2tensor(img, change_range=True)
if bool(os.environ["isFp16"]):
if os.environ["isFp16"] == "True":
model = model.half()
logger.info("Upscaling image")
t_out, _ = auto_split_process(
Expand Down
2 changes: 1 addition & 1 deletion backend/nodes/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def auto_split_process(
if max_depth is None or max_depth == current_depth:
try:
d_img = lr_img.to(torch.device(os.environ["device"]))
if bool(os.environ["isFp16"]):
if os.environ["isFp16"] == "True":
d_img = d_img.half()
result = model(d_img).detach().cpu()
del d_img
Expand Down
5 changes: 3 additions & 2 deletions backend/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ async def run(request: Request):
full_data = request.json
logger.info(full_data)
nodes_list = full_data["data"]
os.environ["device"] = "cpu" if bool(full_data["isCpu"]) else "cuda"
os.environ["device"] = "cpu" if full_data["isCpu"] else "cuda"
os.environ["isFp16"] = (
"False" if bool(full_data["isCpu"]) else str(full_data["isFp16"])
"False" if full_data["isCpu"] else str(full_data["isFp16"])
)
logger.info(f"Using device: {os.environ['device']}")
os.environ["resolutionX"] = str(full_data["resolutionX"])
os.environ["resolutionY"] = str(full_data["resolutionY"])
executor = Executor(nodes_list, app.loop, queue)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chainner",
"productName": "chaiNNer",
"version": "0.2.0",
"version": "0.2.1",
"description": "A flowchart based image processing GUI",
"main": ".webpack/main",
"scripts": {
Expand Down

0 comments on commit 5206c69

Please sign in to comment.