openfree commited on
Commit
04bc9b2
·
verified ·
1 Parent(s): 0d770e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -21
app.py CHANGED
@@ -16,7 +16,7 @@ if not os.path.exists(SAVE_DIR):
16
 
17
  device = "cuda" if torch.cuda.is_available() else "cpu"
18
  repo_id = "black-forest-labs/FLUX.1-dev"
19
- adapter_id = "openfree/korea-president-yoon"
20
 
21
  pipeline = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.bfloat16)
22
  pipeline.load_lora_weights(adapter_id)
@@ -47,8 +47,11 @@ def load_generated_images():
47
  return []
48
 
49
  # Load all images from the directory
50
- image_files = [os.path.join(SAVE_DIR, f) for f in os.listdir(SAVE_DIR)
51
- if f.endswith(('.png', '.jpg', '.jpeg', '.webp'))]
 
 
 
52
  # Sort by creation time (newest first)
53
  image_files.sort(key=lambda x: os.path.getctime(x), reverse=True)
54
  return image_files
@@ -57,6 +60,19 @@ def load_predefined_images():
57
  # Return empty list since we're not using predefined images
58
  return []
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  @spaces.GPU(duration=120)
61
  def inference(
62
  prompt: str,
@@ -90,35 +106,33 @@ def inference(
90
  return image, seed, load_generated_images()
91
 
92
  examples = [
93
- "A man playing fetch with a golden retriever in a sunny park. He wears casual weekend clothes and throws a red frisbee with joy. The dog leaps gracefully through the air, tail wagging with excitement. Warm afternoon sunlight filters through the trees, creating a peaceful scene of companionship. [president yoon]",
94
 
95
- "A soldier standing at attention in full military gear, holding a standard-issue rifle. His uniform is crisp and properly adorned with medals. Behind him, other soldiers march in formation during a military parade. The scene conveys discipline and duty. [president yoon]",
96
 
97
- "A medieval knight in gleaming armor, holding an ornate sword and shield. He stands proudly in front of a majestic castle, his cape flowing in the wind. The shield bears intricate heraldic designs, and sunlight glints off his polished armor. [president yoon]",
98
 
99
- "A charismatic political leader addressing a crowd from a podium. He wears a well-fitted suit and gestures confidently while speaking. The audience fills a large plaza, holding supportive banners and signs. News cameras capture the moment as he delivers his speech. [president yoon]",
100
 
101
- "A man enjoying a peaceful morning at home, reading a newspaper at his breakfast table. He wears comfortable home clothes and sips coffee from a favorite mug. Sunlight streams through the kitchen window, and a house plant adds a touch of nature to the cozy domestic scene. [president yoon]",
102
 
103
- "A businessman walking confidently through a modern office building. He carries a leather briefcase and wears a tailored navy suit. Floor-to-ceiling windows reveal a cityscape behind him, and his expression shows determination and purpose. [president yoon]"
104
  ]
105
 
106
- css = """
107
- footer {
108
- visibility: hidden;
109
- }
110
- """
111
 
112
- with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css, analytics_enabled=False) as demo:
113
- gr.HTML('<div class="title"> President Yoon in KOREA </div>')
 
114
 
115
- gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-korea-president-yoon.hf.space">
116
- <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-korea-president-yoon.hf.space&countColor=%23263759" />
117
- </a>""")
 
 
118
 
119
  with gr.Tabs() as tabs:
120
  with gr.Tab("Generation"):
121
- with gr.Column(elem_id="col-container"):
122
  with gr.Row():
123
  prompt = gr.Text(
124
  label="Prompt",
@@ -226,4 +240,4 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css, analytics_enabled=Fa
226
  )
227
 
228
  demo.queue()
229
- demo.launch()
 
16
 
17
  device = "cuda" if torch.cuda.is_available() else "cpu"
18
  repo_id = "black-forest-labs/FLUX.1-dev"
19
+ adapter_id = "openfree/pepe"
20
 
21
  pipeline = DiffusionPipeline.from_pretrained(repo_id, torch_dtype=torch.bfloat16)
22
  pipeline.load_lora_weights(adapter_id)
 
47
  return []
48
 
49
  # Load all images from the directory
50
+ image_files = [
51
+ os.path.join(SAVE_DIR, f)
52
+ for f in os.listdir(SAVE_DIR)
53
+ if f.endswith(('.png', '.jpg', '.jpeg', '.webp'))
54
+ ]
55
  # Sort by creation time (newest first)
56
  image_files.sort(key=lambda x: os.path.getctime(x), reverse=True)
57
  return image_files
 
60
  # Return empty list since we're not using predefined images
61
  return []
62
 
63
+ # 간단한 CSS: 타이틀 크기, 중앙 정렬, footer 숨김 등
64
+ css = """
65
+ .title {
66
+ font-size: 1.8em;
67
+ font-weight: bold;
68
+ text-align: center;
69
+ margin: 20px 0;
70
+ }
71
+ footer {
72
+ visibility: hidden;
73
+ }
74
+ """
75
+
76
  @spaces.GPU(duration=120)
77
  def inference(
78
  prompt: str,
 
106
  return image, seed, load_generated_images()
107
 
108
  examples = [
109
+ "Pepe the frog playing fetch with a golden retriever in a sunny park. He wears casual weekend clothes and tosses a bright red frisbee with a goofy grin. The dog leaps gracefully through the air, tail wagging with excitement. The warm afternoon sunlight filters through the trees, creating a humorous meme-like atmosphere. [pepe]",
110
 
111
+ "Pepe the frog dressed in full military gear, standing at attention with a standard-issue rifle. His crisp uniform is adorned with cartoonish medals. Other frog soldiers march in formation behind him during a grand meme parade, conveying discipline mixed with comical charm. [pepe]",
112
 
113
+ "A medieval Pepe knight in gleaming armor, proudly holding an ornate sword and shield. He stands in front of a majestic castle with a swirling moat. His shield features a cartoon frog crest, and sunlight gleams off his polished armor, adding a humorous yet epic feel. [pepe]",
114
 
115
+ "A charismatic Pepe the frog addressing a crowd from a podium. He wears a well-fitted suit and gestures with exaggerated cartoon expressions while speaking. The audience is filled with fellow frog characters holding supportive banners. Cameras capture this grand meme moment. [pepe]",
116
 
117
+ "Pepe the frog enjoying a peaceful morning at home, reading a newspaper at his kitchen table. He wears comfy pajamas and sips coffee from a novelty frog mug. Sunlight streams through the window, illuminating a quaint plant on the countertop in this cozy, meme-inspired scene. [pepe]",
118
 
119
+ "Businessman Pepe walking confidently through a sleek office lobby, briefcase in hand. He wears a tailored navy suit, and his wide frog eyes convey determination. Floor-to-ceiling windows reveal a bustling cityscape behind him, blending corporate professionalism with meme humor. [pepe]"
120
  ]
121
 
 
 
 
 
 
122
 
123
+ # Blocks에서 기존 theme 제거 css만 적용
124
+ with gr.Blocks(css=css, analytics_enabled=False) as demo:
125
+ gr.HTML('<div class="title"> PEPE Meme Generator </div>')
126
 
127
+ gr.HTML("""
128
+ <a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-pepe.hf.space">
129
+ <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-pepe.hf.space&countColor=%23263759" />
130
+ </a>
131
+ """)
132
 
133
  with gr.Tabs() as tabs:
134
  with gr.Tab("Generation"):
135
+ with gr.Column():
136
  with gr.Row():
137
  prompt = gr.Text(
138
  label="Prompt",
 
240
  )
241
 
242
  demo.queue()
243
+ demo.launch()