TryChAI commited on
Commit
21f7c68
·
1 Parent(s): bf487f4

Update index.html (#1)

Browse files

- Update index.html (563002214ff0a61d597b13e0f05eb0c1e67799e8)

Files changed (1) hide show
  1. index.html +118 -18
index.html CHANGED
@@ -1,19 +1,119 @@
1
- <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="w-100 text-center"><p class="h6"><!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <title>Midjourney Prompt Generator</title>
5
+ <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
6
+ </head>
7
+ <body>
8
+ <div class="container mt-5">
9
+ <h1 class="text-center">Midjourney Prompt Machine</h1>
10
+ <form id="promptForm">
11
+ <div class="form-group">
12
+ <label for="description">Enter Description:</label>
13
+ <textarea class="form-control" id="description" name="description" rows="6" required></textarea>
14
+ </div>
15
+ <div class="form-group">
16
+ <label for="numPrompts">Number of prompts to output:</label>
17
+ <input class="form-control" id="numPrompts" name="numPrompts" value="4" min="1" max="5" type="number" required></textarea>
18
+ </div>
19
+ <button type="submit" class="btn btn-primary">Generate Prompt</button>
20
+ </form>
21
+
22
+ <hr>
23
+
24
+ <div id="outputDiv" class="mt-4"></div>
25
+ <button id="copyButton" class="btn btn-secondary mt-2">Copy Text</button>
26
+
27
+ </div>
28
+
29
+ <script>
30
+ const apiKey = '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'; // Replace with your actual API key
31
+ const apiUrl = 'https://api.openai.com/v1/chat/completions';
32
+ const responseDiv = document.getElementById('outputDiv');
33
+
34
+ function generateResponse(prompt) {
35
+ const data = {
36
+ model: 'gpt-3.5-turbo',
37
+ messages: [{ role: 'system', content: 'You are a prompt generator for Midjourney.' }, { role: 'user', content: prompt }],
38
+ };
39
+
40
+ fetch(apiUrl, {
41
+ method: 'POST',
42
+ headers: {
43
+ 'Content-Type': 'application/json',
44
+ 'Authorization': `Bearer ${apiKey}`,
45
+ },
46
+ body: JSON.stringify(data),
47
+ })
48
+ .then(response => response.json())
49
+ .then(data => {
50
+ const reply = data.choices[0].message.content;
51
+ responseDiv.innerHTML = `<p>${reply}</p>`;
52
+ })
53
+ .catch(error => {
54
+ console.error('Error:', error);
55
+ responseDiv.innerHTML = `<p><strong>Error:</strong> ${error}</p>`;
56
+ });
57
+ }
58
+
59
+ document.getElementById('promptForm').addEventListener('submit', function(event) {
60
+ event.preventDefault();
61
+ const letterNums = ['zero','one', 'two', 'three', 'four', 'five'];
62
+ const description = document.getElementById('description').value;
63
+ let numPrompts = parseInt(document.getElementById('numPrompts').value);
64
+ numPrompts = letterNums[numPrompts].toUpperCase();
65
+ const formattedPrompt = `<p>
66
+ As a prompt generator for a generative AI called "Midjourney", you will create image prompts for the AI to visualize. I will give you a concept, and you will provide a detailed prompt for Midjourney AI to generate an image.
67
+
68
+ Please adhere to the structure and formatting below, and follow these guidelines:
69
+
70
+ - Do not use the words "description" or ":" in any form.
71
+ - Do not place a comma between [ar] and [v].
72
+ - Write each prompt in one line without using return.
73
+
74
+ Structure:
75
+ [1] = ${description}
76
+ [2] = a detailed description of [1] with specific imagery details.
77
+ [3] = a detailed description of the scene's environment.
78
+ [4] = a detailed description of the scene's mood, feelings, and atmosphere.
79
+ [5] = A style (e.g. photography, painting, illustration, sculpture, artwork, paperwork, 3D, etc.) for [1].
80
+ [6] = A description of how [5] will be executed (e.g. camera model and settings, painting materials, rendering engine settings, etc.)
81
+ [ar] = Use "--ar 16:9" for horizontal images, "--ar 9:16" for vertical images, or "--ar 1:1" for square images.
82
+ [v] = Use "--niji" for Japanese art style, or "--v 5" for other styles.
83
+
84
+ Formatting:
85
+ Follow this prompt structure: "/imagine prompt: [1], [2], [3], [4], [5], [6], [ar] [v]".
86
+
87
+ Your task: Create '${numPrompts}' distinct prompt${(numPrompts=='one')?'':'s'} (and just ${numPrompts} please! not more not less) for each concept [1], varying in description, environment, atmosphere, and realization.
88
+
89
+ - Write your prompts in English.
90
+ - Do not describe unreal concepts as "real" or "photographic".
91
+ - Include one realistic photographic style prompt with lens type and size.
92
+ - Separate different prompts with two new lines.
93
+
94
+ Example Prompts:
95
+ Prompt 1:
96
+ /imagine prompt: A stunning Halo Reach landscape with a Spartan on a hilltop, lush green forests surround them, clear sky, distant city view, focusing on the Spartan's majestic pose, intricate armor, and weapons, Artwork, oil painting on canvas, --ar 16:9 --v 5
97
+
98
+ Prompt 2:
99
+ /imagine prompt: A captivating Halo Reach landscape with a Spartan amidst a battlefield, fallen enemies around, smoke and fire in the background, emphasizing the Spartan's determination and bravery, detailed environment blending chaos and beauty, Illustration, digital art, --ar 16:9 -- v 5
100
+ </p>`;
101
+ responseDiv.innerHTML = '<p>Generating...<br>Please wait!</p>';
102
+
103
+ generateResponse(formattedPrompt);
104
+ });
105
+
106
+ document.getElementById('copyButton').addEventListener('click', function() {
107
+ const promptText = document.getElementById('outputDiv').innerText;
108
+ const textArea = document.createElement('textarea');
109
+ textArea.value = promptText;
110
+ document.body.appendChild(textArea);
111
+ textArea.select();
112
+ document.execCommand('copy');
113
+ document.body.removeChild(textArea);
114
+
115
+ alert('Prompt text copied to clipboard!');
116
+ });
117
+ </script>
118
+ </body>
119
+ </html></p></div>