mirror of
https://github.com/wassname/multifit.git
synced 2026-09-09 11:27:26 +08:00
from_pretrained
This commit is contained in:
+2
-2
@@ -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())
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user