model download featrue

This commit is contained in:
Sander Land committed 2020-06-21 19:25:12 +02:00
1 parent f652f412af
commit 6d8bd7206f
18 files changed
+91 -23

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ class KataGoEngine:
self.query_counter = 0
self.katago_process = None
self.base_priority = 0
self.override_settings = {} # mainly for bot scripts to hook into
self.override_settings = {'reportAnalysisWinratesAs':'BLACK'} # mainly for bot scripts to hook into
self._lock = threading.Lock()
self.analysis_thread = None
self.stderr_thread = None
+19 -7
View File
@@ -338,14 +338,18 @@ class ConfigAIPopup(QuickConfigGui):
class ConfigPopup(QuickConfigGui):
def __init__(self, katrain):
super().__init__(katrain)
self.paths = [self.katrain.config("engine/model"), "katrain/models", "~/.katrain"]
def build_and_set_properties(self, *_args):
super().build_and_set_properties()
def check_models(self, *args): # WIP
paths = [self.model_path.text, self.katrain.config("engine/model"), "katrain/models", "~/.katrain"]
done = set()
model_files = []
for path in paths:
for path in self.paths + [self.model_path.text]:
path = path.rstrip("/\\")
if path.startswith("katrain"):
path = path.replace("katrain", PATHS["PACKAGE"].rstrip("/\\"), 1)
@@ -355,17 +359,25 @@ class ConfigPopup(QuickConfigGui):
if slashpath in done or not os.path.isdir(path):
continue
done.add(slashpath)
model_files += [
files = [
f.replace("/", os.path.sep).replace(PATHS["PACKAGE"], "katrain")
for ftype in ["*.bin.gz", "*.txt.gz"]
for f in glob.glob(slashpath + "/" + ftype)
]
self.model_files.values = model_files
if files and path not in self.paths:
self.paths.append(path) # persistent on paths with models found
model_files += files
models_available_msg = i18n._("models available").format(num=len(model_files))
self.model_files.values = [models_available_msg] + model_files
self.model_files.text = models_available_msg
MODELS = {
"20b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b20c256x2-s4384473088-d968438914.bin.gz",
"30b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b30c320x2-s3530176512-d968463914.bin.gz",
"40b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b40c256x2-s3708042240-d967973220.bin.gz",
# "pure 20b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b20c256x2-s4384473088-d968438914.bin.gz",
# "pure 30b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b30c320x2-s3530176512-d968463914.bin.gz",
# "pure 40b": "https://github.com/lightvector/KataGo/releases/download/v1.4.0/g170-b40c256x2-s3708042240-d967973220.bin.gz",
"final 20b":"https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170e-b20c256x2-s5303129600-d1228401921.bin.gz",
"final 30b": "https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170-b30c320x2-s4824661760-d1229536699.bin.gz",
"final 40b":"https://github.com/lightvector/KataGo/releases/download/v1.4.5/g170-b40c256x2-s5095420928-d1229425124.bin.gz"
}
def download_models(self, *_largs):
+2 -1
View File
@@ -98,11 +98,12 @@ class ProgressLoader(BoxLayout):
pass
def update_progress(self, request, current_size, total_size):
if total_size < 1e4:
current_size = 0
percent = current_size * 100 // max(total_size, 1)
self.label_downloading_text = self.downloading_text.format(percent)
def on_success(self, request, result):
Clock.schedule_once(self.animation_hide, 0)
self.root_instance.remove_widget(self)
if self.download_complete:
self.download_complete(request)
Binary file not shown.
@@ -556,3 +556,11 @@ msgstr ""
msgid "Starting Kata failed"
msgstr ""
"用'{command}'命令启动katago出错 {error}. 请确认引擎设置里'katago'的值指向了 正确的KataGo运行文件."
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
Binary file not shown.
@@ -599,3 +599,11 @@ msgstr "Analyse der Kandidatenzüge wird abgeglichen mit {visits} Visits"
msgid "sweep analysis"
msgstr "Analysiere gesamtes Brett mit {visits} Visits/Zug"
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
Binary file not shown.
@@ -593,5 +593,8 @@ msgstr ""
"one. Stronger settings select the best move from a larger selection. Since "
"there is no 0 kyu/dan, 3 dan = -2 kyu."
msgid "Download Models"
msgstr Download Models"
msgid "download models button"
msgstr "Download Models"
msgid "models available"
msgstr "{num} available model(s) found"
Binary file not shown.
@@ -594,3 +594,11 @@ msgstr ""
msgid "extra analysis"
msgstr "Realizar análisis adicional a {visits} visitas"
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
Binary file not shown.
@@ -633,3 +633,11 @@ msgstr ""
"Plus kyu_rank (-3~18) est bas, plus l'échantillon sera large et le niveau de jeu élevé. \n"
"Une valeur positive équivaudra à un niveau en kyu, 0 à 1er dan, -1 à 2e dan, etc. \n"
"(Niveaux estimés sur OGS avec le réseau neuronal utilisé PAR DÉFAUT)"
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
Binary file not shown.
@@ -571,3 +571,11 @@ msgstr "모든 후보수를 균일하게 {visits} visits으로 분석합니다."
msgid "extra analysis"
msgstr "{visits} visits까지 추가적으로 분석하고 있습니다."
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
Binary file not shown.
@@ -596,3 +596,11 @@ msgstr ""
"Выбирает случайные ходы из ограниченного множества и играет лучший из них. "
"Более сильные настройки расширяют множество для выбора. Т.к. на шкале "
"отсутствуют 0 кю/дан, то 3 дан = -2 кю."
#. TODO
msgid "models available"
msgstr "{num} available model(s) found"
#. TODO
msgid "download models button"
msgstr "Download Models"
+16 -12
View File
@@ -108,22 +108,26 @@
DescriptionLabel:
text: i18n._("engine:model")
size_hint: 0.33, 1
LabelledPathInput:
id: model_path
input_property: "engine/model"
on_text: root.check_models()
AnchorLayout:
LabelledPathInput:
id: model_path
input_property: "engine/model"
on_text: root.check_models()
AnchorLayout:
size_hint: 0.33, 1
AutoSizedRoundedRectangleButton:
text: i18n._("Download Models")
text: i18n._("download models button")
on_press: root.download_models()
size_hint_y: 0.8
Spinner:
id: model_files
text: ''
on_text: if self.text: model_path.text = self.text
-font_size: self.height * 0.33
-background_color: [*[c*255/88 for c in BOX_BACKGROUND_COLOR[:3]], 1] # compensate for texture
size_hint_y: 0.7
AnchorLayout:
Spinner:
id: model_files
text: ''
on_text: if self.text and self.text != self.values[0]: model_path.text = self.text
size_hint_y: 0.7
sync_height_frac: 1.0
-font_size: self.height * 0.5
-background_color: [*[c*255/88 for c in BOX_BACKGROUND_COLOR[:3]], 1] # compensate for texture
BoxLayout:
size_hint: 1,1
orientation: 'horizontal'