maldons77 commited on
Commit
093d678
·
verified ·
1 Parent(s): 40541fb

Upload 6 files

Browse files
Files changed (6) hide show
  1. LICENSE +21 -0
  2. README.md +43 -0
  3. card.png +0 -0
  4. inference.py +36 -0
  5. model.joblib +3 -0
  6. requirements.txt +3 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Eric Maldon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pipeline_tag: text-classification
5
+ license: mit
6
+ tags:
7
+ - storyboard
8
+ - beats
9
+ - style-suggestion
10
+ - nlp
11
+ - sklearn
12
+ - educational
13
+ model-index:
14
+ - name: StoryboardBeats-Mini-0.1
15
+ results: []
16
+ ---
17
+
18
+ # StoryboardBeats-Mini v0.1
19
+
20
+ **What it does**
21
+ Given a short story prompt, this model predicts:
22
+ - **Narrative beats** (multi-label): `opening`, `rising_action`, `key_moment`, `twist`, `resolution`
23
+ - **Suggested visual style**: `Realistic`, `Anime`, `Comic`, `Watercolor`, or `Sketch`
24
+
25
+ **Why it's unique**
26
+ A tiny, proprietary prototype that links **text prompts** to **story structure** and **visual style** — designed for pre-visualization workflows. Lightweight and CPU-friendly (scikit‑learn).
27
+
28
+ ## Files
29
+ - `model.joblib` — scikit-learn pipelines (TF‑IDF + Logistic Regression) for beats (multi-label) and style.
30
+ - `inference.py` — minimal interface with `load_model()` and `predict()`.
31
+ - `requirements.txt` — dependencies to run `inference.py`.
32
+
33
+ ## Quick use (local)
34
+ ```bash
35
+ pip install -r requirements.txt
36
+ python -c "import inference; print(inference.predict(['A robot in a neon city discovers a secret, but time runs out.']))"
37
+ ```
38
+
39
+ ## Metrics (synthetic split)
40
+ - beats (subset accuracy): **0.717**
41
+ - style (accuracy): **1.000**
42
+
43
+ > ⚠️ Trained on synthetic data; not suitable for production. Educational / research use only.
card.png ADDED
inference.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ from typing import List, Dict
3
+
4
+ ARTIFACT_PATH = "model.joblib"
5
+ _model = None
6
+
7
+ def load_model():
8
+ global _model
9
+ if _model is None:
10
+ _model = joblib.load(ARTIFACT_PATH)
11
+ return _model
12
+
13
+ def predict(inputs: List[str]) -> Dict:
14
+ """
15
+ Inputs: list of prompts (strings)
16
+ Returns: dict with beats (multi-label) and style for each input
17
+ """
18
+ model = load_model()
19
+ beats_clf = model["beats_model"]
20
+ style_clf = model["style_model"]
21
+ beats_classes = model["beats_classes"]
22
+ # Beats probabilities -> threshold 0.5
23
+ beats_proba = beats_clf.predict_proba(inputs)
24
+ beats_pred = (beats_proba >= 0.5).astype(int)
25
+ # Style label
26
+ style_pred = style_clf.predict(inputs)
27
+ results = []
28
+ for i, text in enumerate(inputs):
29
+ beats = [b for b, v in zip(beats_classes, beats_pred[i]) if v == 1]
30
+ results.append({
31
+ "input": text,
32
+ "beats": beats,
33
+ "style": str(style_pred[i]),
34
+ "beats_proba": {b: float(p) for b, p in zip(beats_classes, beats_proba[i])}
35
+ })
36
+ return {"results": results}
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3d859b303324de2e96fdcb6110b231ba36806470a62075202cd6d65d3f97918
3
+ size 38088
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ scikit-learn>=1.2
2
+ joblib>=1.3
3
+ numpy>=1.24