Spaces:
Runtime error
Runtime error
added small application
Browse files- app.py +72 -0
- config.yml +12 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import yaml
|
| 3 |
+
from gradio.themes.utils import colors
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
bfh_blue = colors.Color(
|
| 7 |
+
c50="#edf0f2",
|
| 8 |
+
c100="#dbe0e5",
|
| 9 |
+
c200="#b7c1cb",
|
| 10 |
+
c300="#93a2b1",
|
| 11 |
+
c400="#6f8397",
|
| 12 |
+
c500="#4b647d",
|
| 13 |
+
c600="#3c5064",
|
| 14 |
+
c700="#2d3c4b",
|
| 15 |
+
c800="#1e2832",
|
| 16 |
+
c900="#0f1419",
|
| 17 |
+
c950="#070a0c",
|
| 18 |
+
name="bfh_blue",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
bfh_yellow = colors.Color(
|
| 22 |
+
c50="#fff9e6",
|
| 23 |
+
c100="#fef3cc",
|
| 24 |
+
c200="#fde799",
|
| 25 |
+
c300="#fcdb66",
|
| 26 |
+
c400="#fbcf33",
|
| 27 |
+
c500="#fac300",
|
| 28 |
+
c600="#c89c00",
|
| 29 |
+
c700="#967500",
|
| 30 |
+
c800="#644e00",
|
| 31 |
+
c900="#322700",
|
| 32 |
+
c950="#191300",
|
| 33 |
+
name="bfh_yellow",
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class BFHTheme(gr.themes.Base):
|
| 38 |
+
def __init__(
|
| 39 |
+
self,
|
| 40 |
+
):
|
| 41 |
+
super().__init__(
|
| 42 |
+
primary_hue=bfh_blue,
|
| 43 |
+
secondary_hue=bfh_yellow,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
class InterfaceCreator:
|
| 47 |
+
@staticmethod
|
| 48 |
+
def read_yaml(path):
|
| 49 |
+
with open(path) as f:
|
| 50 |
+
return yaml.safe_load(f)
|
| 51 |
+
@classmethod
|
| 52 |
+
def from_yaml(cls, path):
|
| 53 |
+
"""Initializes Interface from YAML file."""
|
| 54 |
+
content_dict = cls.read_yaml(path)
|
| 55 |
+
return cls.create_interface(**content_dict)
|
| 56 |
+
|
| 57 |
+
@classmethod
|
| 58 |
+
def create_interface(cls, name, title=None, description=None, examples=None):
|
| 59 |
+
"""Creates Gradio-Element containing an interface."""
|
| 60 |
+
interface = gr.load(
|
| 61 |
+
name,
|
| 62 |
+
title=None,
|
| 63 |
+
description=description,
|
| 64 |
+
examples=examples,
|
| 65 |
+
theme=BFHTheme(),
|
| 66 |
+
)
|
| 67 |
+
return interface
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
if __name__=="__main__":
|
| 71 |
+
interface = InterfaceCreator.from_yaml("config.yml")
|
| 72 |
+
interface.launch()
|
config.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
title: GPT2 # will be used as tab title and for the link.
|
| 2 |
+
name: huggingface/gpt2 # path to model
|
| 3 |
+
description: >
|
| 4 |
+
Dies ist ein Vorläufermodell von
|
| 5 |
+
GPT-3.5, auf dem ChatGPT beruht. Das Modell vervollständigt eingegebene Texte, in dem
|
| 6 |
+
es immer ein wahrscheinliches nächstes Wort voraussagt. Allerdings hat es auch einen
|
| 7 |
+
kleinen Zufallsfaktor, damit der gleiche Input nicht immer das gleiche Resultat liefern.
|
| 8 |
+
Das hier vorgestellte deutschsprachige GPT-2 Modell hat 124 Millionen Parameter, ist also
|
| 9 |
+
1400x kleiner als ChatGPT - und somit auch erkennbar schlechter in der Textgenerierung.
|
| 10 |
+
examples:
|
| 11 |
+
- Paris is the capital of
|
| 12 |
+
- Auf Deutsch funktioniert das Modell deutlich
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pyyaml
|