From 31ee18298327d5d1a8fc26664d69a6a5c11c2dab Mon Sep 17 00:00:00 2001 From: Tare Ebelo <75279482+TareHimself@users.noreply.github.com> Date: Mon, 11 Sep 2023 20:43:08 -0400 Subject: [PATCH 1/2] removed paste option for ui --- extractor.py | 23 ------ tile_search.py | 78 +++++++++++++++++++ translator/cleaners/deepfillv2.py | 9 ++- ui/build/asset-manifest.json | 6 +- ui/build/index.html | 2 +- .../js/{main.a6910cdf.js => main.774d98f5.js} | 6 +- ...CENSE.txt => main.774d98f5.js.LICENSE.txt} | 0 ui/build/static/js/main.774d98f5.js.map | 1 + ui/build/static/js/main.a6910cdf.js.map | 1 - ui/src/redux/slices/app.ts | 2 +- 10 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 tile_search.py rename ui/build/static/js/{main.a6910cdf.js => main.774d98f5.js} (92%) rename ui/build/static/js/{main.a6910cdf.js.LICENSE.txt => main.774d98f5.js.LICENSE.txt} (100%) create mode 100644 ui/build/static/js/main.774d98f5.js.map delete mode 100644 ui/build/static/js/main.a6910cdf.js.map diff --git a/extractor.py b/extractor.py index 10d47f9..a76b293 100644 --- a/extractor.py +++ b/extractor.py @@ -213,29 +213,6 @@ def get_other_refs(tree: ast.AST,exclude: list[str]) -> dict[str,ast.AST]: deps[node_name] = node return deps - -def try_build_module_path(current: str,remaining: list[str],max_lookaheads = 1) -> Union[str,None]: - - if len(remaining) == 0: - if os.path.exists(current) and os.path.isfile(current): - return current - return None - - new_path = os.path.join(current,remaining[0]) - - if os.path.exists(new_path): - return try_build_module_path(new_path,remaining[1:]) - else: - for i in range(max_lookaheads): - delta = i + 1 - if len(remaining) <= delta: - break - - test_path = os.path.join(current,remaining[delta]) - if os.path.exists(delta): - return try_build_module_path(test_path,remaining[delta:]) - - return None paths_cache: dict[str,str] = {} diff --git a/tile_search.py b/tile_search.py new file mode 100644 index 0000000..aa645cf --- /dev/null +++ b/tile_search.py @@ -0,0 +1,78 @@ +from collections import deque + +# 123 +# 456 +# 78X + +# 123 +# 4X5 +# 678 + +target_state = ["1","2","3","4","X","5","6","7","8"] + + + +def serialize_state(a: list[str]) -> str: + return ".".join(a) + + +def compare_states(a: list[str],b: list[str]) -> bool: + return serialize_state(a) == serialize_state(b) + + +def create_new_state(state: list[str],position: int,new_position: int) -> list[str]: + arr = state.copy() + temp = arr[new_position] + arr[new_position] = arr[position] + arr[position] = temp + return arr + +def search(start: list[str]): + states_to_search:deque[list[str]] = deque() + states_to_search.append(start) + searched_states = set([serialize_state(start)]) + + iterations = 0 + while len(states_to_search) > 0: + iterations += 1 + + current_state = states_to_search.popleft() + + if compare_states(current_state,target_state): + print(f"Solved after {iterations} iterations") + print(current_state) + return True + + position_in_state = current_state.index('X') + + possible_destinations = [] + if position_in_state == 0: + possible_destinations.extend([1,3]) + elif position_in_state == 1: + possible_destinations.extend([0,4,2]) + elif position_in_state == 2: + possible_destinations.extend([2,5]) + elif position_in_state == 3: + possible_destinations.extend([0,4,6]) + elif position_in_state == 4: + possible_destinations.extend([1,5,7,3]) + elif position_in_state == 5: + possible_destinations.extend([2,4,8]) + elif position_in_state == 6: + possible_destinations.extend([3,7]) + elif position_in_state == 7: + possible_destinations.extend([4,8,6]) + elif position_in_state == 8: + possible_destinations.extend([5,7]) + + for dest in possible_destinations: + resulting_state = create_new_state(current_state,position_in_state,dest) + + if serialize_state(resulting_state) not in searched_states: + states_to_search.append(resulting_state) + searched_states.add(serialize_state(resulting_state)) + + print(f"Failed to find solution after {iterations} iterations") + +puzzle = ["1","X","3","4","5","6","7","8","2"] +search(puzzle) \ No newline at end of file diff --git a/translator/cleaners/deepfillv2.py b/translator/cleaners/deepfillv2.py index b4102c0..b84ace9 100644 --- a/translator/cleaners/deepfillv2.py +++ b/translator/cleaners/deepfillv2.py @@ -162,7 +162,10 @@ def __init__(self) -> None: @staticmethod def get_name() -> str: return "Deep Fill V2" - + + async def clean_section(self,frame: np.ndarray,mask: np.ndarray) -> np.ndarray: + return pil_to_cv2(DeepFillV2Cleaner.in_paint(cv2_to_pil(frame),cv2_to_pil(mask))) + async def clean( self, frame: ndarray, @@ -174,7 +177,5 @@ async def clean( frame, mask=mask, filtered=detection_results, # segmentation_results.boxes.xyxy.cpu().numpy() - inpaint_fun=lambda frame, mask: loop.create_task(DeepFillV2Cleaner.add_in_paint_task( - frame, mask - )), + inpaint_fun=lambda frame, mask: loop.create_task(self.clean_section(frame,mask)), ) diff --git a/ui/build/asset-manifest.json b/ui/build/asset-manifest.json index 4820754..89c6dda 100644 --- a/ui/build/asset-manifest.json +++ b/ui/build/asset-manifest.json @@ -1,15 +1,15 @@ { "files": { "main.css": "/static/css/main.bd8e5710.css", - "main.js": "/static/js/main.a6910cdf.js", + "main.js": "/static/js/main.774d98f5.js", "static/js/787.776d5c80.chunk.js": "/static/js/787.776d5c80.chunk.js", "index.html": "/index.html", "main.bd8e5710.css.map": "/static/css/main.bd8e5710.css.map", - "main.a6910cdf.js.map": "/static/js/main.a6910cdf.js.map", + "main.774d98f5.js.map": "/static/js/main.774d98f5.js.map", "787.776d5c80.chunk.js.map": "/static/js/787.776d5c80.chunk.js.map" }, "entrypoints": [ "static/css/main.bd8e5710.css", - "static/js/main.a6910cdf.js" + "static/js/main.774d98f5.js" ] } \ No newline at end of file diff --git a/ui/build/index.html b/ui/build/index.html index 75bd852..f9d4f80 100644 --- a/ui/build/index.html +++ b/ui/build/index.html @@ -1 +1 @@ -Manga Translator Sample
\ No newline at end of file +Manga Translator Sample
\ No newline at end of file diff --git a/ui/build/static/js/main.a6910cdf.js b/ui/build/static/js/main.774d98f5.js similarity index 92% rename from ui/build/static/js/main.a6910cdf.js rename to ui/build/static/js/main.774d98f5.js index 775227a..2636d3a 100644 --- a/ui/build/static/js/main.a6910cdf.js +++ b/ui/build/static/js/main.774d98f5.js @@ -1,3 +1,3 @@ -/*! For license information please see main.a6910cdf.js.LICENSE.txt */ -!function(){"use strict";var e={110:function(e,t,n){var r=n(309),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},l={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function u(e){return r.isMemo(e)?l:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=l;var c=Object.defineProperty,s=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!==typeof n){if(h){var a=p(n);a&&a!==h&&e(t,a,r)}var l=s(n);f&&(l=l.concat(f(n)));for(var i=u(t),v=u(n),m=0;m