from_pretrained

This commit is contained in:
Piotr Czapla
2019-10-14 17:18:28 +02:00
parent 5a3fbcecb5
commit b362f2a7cb
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ class Experiment:
def load(self, model_path):
return ulmfit.ULMFiT().load_(Path(model_path))
def download(self):
raise NotImplementedError("implement model fetching")
def from_pretrained(self):
return ulmfit.ULMFiT.from_pretrained
if __name__ == '__main__':
fire.Fire(Experiment())
+12
View File
@@ -462,3 +462,15 @@ class ULMFiT:
{self.finetune_lm},
{self.classifier},
)""")
def from_pretrained_(self, name, repo="PiotrCzapla/multifit-models"):
name = name.rstrip(".tgz") # incase someone put's tgz name the name
url = f"https://github.com/{repo}/releases/download/{name}/{name}.tgz"
path = untar_data(url.rstrip(".tgz"), data=False) # untar_data adds .tgz
return self.load_(path)
@classmethod
def from_pretrained(cls, name):
#TODO: Detect name and load configuration
from . import configurations
return configurations.multifit_paper_version().from_pretrained_(name)