Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[113] save last model selected #114

Open
wants to merge 1 commit into
base: rebase-3.2.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions modules/mod-deep-learning/DeepLearningEffectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ void DeepLearningEffectBase::End()
{
if (manager.IsInstalling(card))
manager.CancelInstall(card);
}
}

// save the selected model
std::string activeModelId = mActiveModel->GetModel()->GetCard()->GetRepoID();
wxConfigBase* config = wxConfigBase::Get();
config->Write(wxT("SelectedModel"), wxString::FromUTF8(activeModelId.c_str()));

// release model (may still be active in thread)
mActiveModel->GetModel()->Offload();
Expand Down Expand Up @@ -347,7 +352,22 @@ std::unique_ptr<EffectUIValidator> DeepLearningEffectBase::PopulateOrExchange(Sh
}
S.EndVerticalLay();

mActiveModel->SetModel(*this);
wxString presetModelNameTemp;
wxConfigBase* config = wxConfigBase::Get();
config->Read(wxT("SelectedModel"), &presetModelNameTemp);

std::string presetModelName(presetModelNameTemp);

try
{
ModelCardHolder presetModel = manager.FetchCard(presetModelName);
mActiveModel->SetModel(*this, presetModel);
}
catch (ModelManagerException &e)
{
wxLogError(wxString(e.what()));
wxLogDebug(wxString(e.what()));
}

return nullptr;
}
19 changes: 19 additions & 0 deletions modules/mod-deep-learning/ModelManagerPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ void ModelManagerPanel::FetchCards()
// prioritize local cards first
manager.FetchLocalCards(onCardFetched);
manager.FetchHuggingFaceCards(onCardFetched);

// set the last used card as the active card
// grab the last used model with wx presets
wxString presetModelNameTemp;
wxConfigBase* config = wxConfigBase::Get();
config->Read(wxT("SelectedModel"), &presetModelNameTemp);

std::string presetModelName(presetModelNameTemp);

try
{
ModelCardHolder presetModel = manager.FetchCard(presetModelName);
mActiveModel->SetModel(*mEffect, presetModel);
}
catch (ModelManagerException &e)
{
wxLogError(wxString(e.what()));
wxLogDebug(wxString(e.what()));
}

}

Expand Down