Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
# URL: https://huggingface.co/spaces/gradio/text_generation
|
2 |
# imports
|
3 |
import gradio as gr
|
4 |
-
from transformers import
|
5 |
import torch
|
6 |
|
7 |
# loading the model
|
8 |
-
tokenizer =
|
9 |
-
model =
|
10 |
|
11 |
# defining the core function
|
12 |
def generate(text):
|
@@ -15,9 +15,8 @@ def generate(text):
|
|
15 |
return result[0]["generated_text"]
|
16 |
|
17 |
|
18 |
-
# defining title
|
19 |
-
title = "Text Generation with GPT-
|
20 |
-
description = "This demo generates text using GPT-J 6B: a transformer model trained using Ben Wang's Mesh Transformer JAX."
|
21 |
examples = [
|
22 |
["The Moon's orbit around Earth has"],
|
23 |
["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
|
|
|
1 |
# URL: https://huggingface.co/spaces/gradio/text_generation
|
2 |
# imports
|
3 |
import gradio as gr
|
4 |
+
from transformers import GPT2Tokenizer, TFGPT2Model
|
5 |
import torch
|
6 |
|
7 |
# loading the model
|
8 |
+
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
9 |
+
model = TFGPT2Model.from_pretrained('gpt2')
|
10 |
|
11 |
# defining the core function
|
12 |
def generate(text):
|
|
|
15 |
return result[0]["generated_text"]
|
16 |
|
17 |
|
18 |
+
# defining title and examples
|
19 |
+
title = "Text Generation with GPT-2"
|
|
|
20 |
examples = [
|
21 |
["The Moon's orbit around Earth has"],
|
22 |
["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
|