Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ class Bergamot:
|
|
| 108 |
model_files = [f.split(f'{self.model_name}/')[1] for f in fullmodel_files]
|
| 109 |
print('branch_files', len(branch_files), 'model_files', model_files)
|
| 110 |
for file_path in model_files:
|
| 111 |
-
if localfolder not in installed_pairs:
|
| 112 |
# local_files_only (bool, optional, defaults to False) — If True, avoid downloading the file and return the path to the local cached file if it exists.
|
| 113 |
# dry_run (bool, optional, defaults to False) — If True, perform a dry run without actually downloading the file. Returns a DryRunFileInfo object containing information about what would be downloaded.
|
| 114 |
local_path = hf_hub_download(repo_id=self.repo_id, subfolder=self.model_name, filename=file_path, local_dir=self.subfolder)
|
|
@@ -124,7 +124,7 @@ class Bergamot:
|
|
| 124 |
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_run', type(dry_run), dry_run)
|
| 125 |
if isinstance(dry_run, str):
|
| 126 |
print('Add to set after dryrun', dry_run)
|
| 127 |
-
self.installed_pairs.add(localfolder)
|
| 128 |
except Exception as dryrunerror:
|
| 129 |
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_runerror', dryrunerror)
|
| 130 |
except Exception as downloaderror:
|
|
@@ -134,7 +134,7 @@ class Bergamot:
|
|
| 134 |
self.downloadbergamotfiles()
|
| 135 |
try:
|
| 136 |
model = self.service.modelFromConfigPath(f"{self.localfolder}/config.yml")
|
| 137 |
-
# model = self.service.modelFromConfig(localfolder)
|
| 138 |
options = bergamot.ResponseOptions(alignment=False, sentenceMappings=False, qualityScores=False, HTML=False)
|
| 139 |
rawresponse = self.service.translate(model, bergamot.VectorString(self.input_text), options)
|
| 140 |
response: list|str = [r.target.text for r in rawresponse] if len(rawresponse) > 1 else next(iter(rawresponse)).target.text
|
|
|
|
| 108 |
model_files = [f.split(f'{self.model_name}/')[1] for f in fullmodel_files]
|
| 109 |
print('branch_files', len(branch_files), 'model_files', model_files)
|
| 110 |
for file_path in model_files:
|
| 111 |
+
if self.localfolder not in installed_pairs:
|
| 112 |
# local_files_only (bool, optional, defaults to False) — If True, avoid downloading the file and return the path to the local cached file if it exists.
|
| 113 |
# dry_run (bool, optional, defaults to False) — If True, perform a dry run without actually downloading the file. Returns a DryRunFileInfo object containing information about what would be downloaded.
|
| 114 |
local_path = hf_hub_download(repo_id=self.repo_id, subfolder=self.model_name, filename=file_path, local_dir=self.subfolder)
|
|
|
|
| 124 |
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_run', type(dry_run), dry_run)
|
| 125 |
if isinstance(dry_run, str):
|
| 126 |
print('Add to set after dryrun', dry_run)
|
| 127 |
+
self.installed_pairs.add(self.localfolder)
|
| 128 |
except Exception as dryrunerror:
|
| 129 |
print('installed_pairs', self.installed_pairs, 'localfolder', self.localfolder, 'dry_runerror', dryrunerror)
|
| 130 |
except Exception as downloaderror:
|
|
|
|
| 134 |
self.downloadbergamotfiles()
|
| 135 |
try:
|
| 136 |
model = self.service.modelFromConfigPath(f"{self.localfolder}/config.yml")
|
| 137 |
+
# model = self.service.modelFromConfig(self.localfolder)
|
| 138 |
options = bergamot.ResponseOptions(alignment=False, sentenceMappings=False, qualityScores=False, HTML=False)
|
| 139 |
rawresponse = self.service.translate(model, bergamot.VectorString(self.input_text), options)
|
| 140 |
response: list|str = [r.target.text for r in rawresponse] if len(rawresponse) > 1 else next(iter(rawresponse)).target.text
|