Skip to content

Commit

Permalink
add filename in model preview popup
Browse files Browse the repository at this point in the history
for #1003
  • Loading branch information
mcmonkey4eva committed Sep 26, 2024
1 parent 05f9999 commit 1c9e82d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/components/sidebar/tabs/modelLibrary/ModelPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{{ modelDef.title }}
</div>
<div class="model_preview_top_container">
<div class="model_preview_filename">
{{ modelDef.name }}
</div>
<div class="model_preview_architecture" v-if="modelDef.architecture_id">
<span class="model_preview_prefix">Architecture: </span>
{{ modelDef.architecture_id }}
Expand Down Expand Up @@ -75,7 +78,9 @@ const modelDef = props.modelDef
}
.model_preview_top_container {
text-align: center;
line-height: 0.5;
}
.model_preview_filename,
.model_preview_author,
.model_preview_architecture {
display: inline-block;
Expand Down
1 change: 1 addition & 0 deletions src/components/sidebar/tabs/modelLibrary/ModelTreeLeaf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const showPreview = computed(() => {
!modelDef.value.is_fake_object &&
modelDef.value.has_loaded_metadata &&
(modelDef.value.author ||
modelDef.value.simplified_name != modelDef.value.title ||
modelDef.value.description ||
modelDef.value.usage_hint ||
modelDef.value.trigger_phrase ||
Expand Down
12 changes: 9 additions & 3 deletions src/stores/modelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class ComfyModelDef {
name: string = ''
/** Directory containing the model, eg 'checkpoints' */
directory: string = ''
/** Simplified copy of name, used as a default title */
simplified_name: string = ''
/** Title / display name of the model, sometimes same as the name but not always */
title: string = ''
/** Metadata: architecture ID for the model, such as 'stable-diffusion-xl-v1-base' */
Expand Down Expand Up @@ -49,10 +51,14 @@ export class ComfyModelDef {

constructor(name: string, directory: string) {
this.name = name
this.title = name.replaceAll('\\', '/').split('/').pop()
if (this.title.endsWith('.safetensors')) {
this.title = this.title.slice(0, -'.safetensors'.length)
this.simplified_name = name.replaceAll('\\', '/').split('/').pop()
if (this.simplified_name.endsWith('.safetensors')) {
this.simplified_name = this.simplified_name.slice(
0,
-'.safetensors'.length
)
}
this.title = this.simplified_name
this.directory = directory
}

Expand Down

0 comments on commit 1c9e82d

Please sign in to comment.