Skip to content

Commit

Permalink
Internal Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 595222708
  • Loading branch information
cpka145 authored and LIT team committed Jan 2, 2024
1 parent a381cb9 commit 1d511ba
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lit_nlp/api/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class FeatureSalience(DataTuple):
class FrameSalience(DataTuple):
"""Dataclass for a salience map over image frames in a video."""

# A map of salience score and image string by frame number
salience: dict[str, tuple[float, str]]
# A map of salience score and image bytes string by frame number
salience: dict[str, tuple[float, Sequence[str]]]


# TODO(b/196886684): document API for salience interpreters.
Expand Down
13 changes: 13 additions & 0 deletions lit_nlp/client/elements/frames_window.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.frames-window-image {
flex: 16.5%;
padding: 5px;
}

#frame {
max-width: 202px;
max-height: 360px;
}

.frames-window {
display: flex;
}
52 changes: 52 additions & 0 deletions lit_nlp/client/elements/frames_window.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* LIT module for displaying a variable size window of image frames.
*/



import {html, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import {styles as sharedStyles} from '../lib/shared_styles.css';

import {styles} from './frames_window.css';

/**
* A LIT module to display variable size list of image frames within a window.
*/
@customElement('lit-frames-window')
export class FramesWindow extends LitElement {
@property({type: Array}) frames: string[] = [];

static override get styles() {
return [
sharedStyles,
styles,
];
}


private renderImage(imgSrc: string) {
return html`
<div class="frames-window-image table-image">
<img id='frame' src="${imgSrc}"></img>
</div>`;
}


override render() {
const framesDOM =
this.frames.map((imageSrc: string) => this.renderImage(imageSrc));

return html`
<div class="frames-window">
${framesDOM}
</div>`;
}
}


declare global {
interface HTMLElementTagNameMap {
'lit-frames-window': FramesWindow;
}
}
2 changes: 1 addition & 1 deletion lit_nlp/client/elements/table_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface SortableTemplateResult {
value: SortableTableEntry;
}
/** Wrapper types for the data supplied to the data table */
export type TableEntry = string|number|TemplateResult|SortableTemplateResult;
export type TableEntry = string|number|string[]|TemplateResult|SortableTemplateResult;

/** Wrapper types for the rows of data supplied to the data table */
export type TableData = TableEntry[]|{[key: string]: TableEntry};
Expand Down
2 changes: 1 addition & 1 deletion lit_nlp/client/lib/dtypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface FeatureSalience extends DataTuple {

/** Dataclass for a salience map over image frames in a video. */
export interface FrameSalience extends DataTuple {
salience: {[key: string]: [number, string]};
salience: {[key: string]: [number, string[]]};
}

// TODO(b/196886684): document API for salience interpreters.
Expand Down

0 comments on commit 1d511ba

Please sign in to comment.