k-l-lambda commited on
Commit
370092f
1 Parent(s): 72164ba

test.ipynb created.

Browse files
Files changed (1) hide show
  1. test.ipynb +143 -0
test.ipynb ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 11,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "api_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'\n",
10
+ "api_path = '/v3/async/instant-id'\n",
11
+ "\n",
12
+ "payload_data = {\n",
13
+ "\t'extra': {\n",
14
+ "\t\t'response_image_type': 'jpeg'\n",
15
+ "\t},\n",
16
+ "\t'model_name': 'sd_xl_base_1.0.safetensors',\n",
17
+ "\t'face_image_assets_ids': [\n",
18
+ "\t\t'cjIvbm92aXRhLWFpLWFzc2V0L2ltYWdlL1JtRDduaU16d3ljTWJOY0hCaXNYM1lwZDNkMnk2YVpl'\n",
19
+ "\t],\n",
20
+ "\t'ref_image_assets_ids': [\n",
21
+ "\t\t'cjIvbm92aXRhLWFpLWFzc2V0L2ltYWdlL1R6WHNyYXdQRlBRZEp6bkJISDd3aHhkU3hOY0ZXc2FD'\n",
22
+ "\t],\n",
23
+ "\t'prompt': 'concept art of a man . digital artwork, illustrative, painterly, matte painting, highly detailed',\n",
24
+ "\t'negative_prompt': 'realistic, photo-realistic, bad quality, bad anatomy, worst quality, low quality, lowres, extra fingers, blur, blurry, ugly, wrong proportions, watermark, image artifacts, bad eyes, bad hands, bad arms',\n",
25
+ "\t'controlnet': {\n",
26
+ "\t\t'units': [\n",
27
+ "\t\t\t{\n",
28
+ "\t\t\t\t'model_name': 'controlnet-openpose-sdxl-1.0',\n",
29
+ "\t\t\t\t'strength': None,\n",
30
+ "\t\t\t\t'guidance_start': None,\n",
31
+ "\t\t\t\t'guidance_end': None,\n",
32
+ "\t\t\t\t'preprocessor': 'openpose'\n",
33
+ "\t\t\t}\n",
34
+ "\t\t]\n",
35
+ "\t},\n",
36
+ "\t'loras': [\n",
37
+ "\t\t{\n",
38
+ "\t\t\t'model_name': 'xl_more_art-full_v1_113467.safetensors',\n",
39
+ "\t\t\t'strength': 0.8\n",
40
+ "\t\t}\n",
41
+ "\t],\n",
42
+ "\t'id_strength': None,\n",
43
+ "\t'adapter_strength': None,\n",
44
+ "\t'width': 768,\n",
45
+ "\t'height': 1024,\n",
46
+ "\t'image_num': 1,\n",
47
+ "\t'steps': 25,\n",
48
+ "\t'seed': -1,\n",
49
+ "\t'guidance_scale': 7.5,\n",
50
+ "\t'sampler_name': 'Euler a',\n",
51
+ "\t'clip_skip': None\n",
52
+ "}\n"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "import requests\n",
62
+ "import json\n",
63
+ "\n",
64
+ "\n",
65
+ "headers = {\n",
66
+ "\t'Content-type': 'application/json',\n",
67
+ "\t'Authorization': f'Bearer {api_key}',\n",
68
+ "}\n",
69
+ "\n",
70
+ "response = requests.request('POST', f'https://api.novita.ai{api_path}', headers=headers, data=json.dumps(payload_data))\n",
71
+ "response.text\n"
72
+ ]
73
+ },
74
+ {
75
+ "cell_type": "code",
76
+ "execution_count": 12,
77
+ "metadata": {},
78
+ "outputs": [
79
+ {
80
+ "data": {
81
+ "text/plain": [
82
+ "{'task_id': 'fe2701c1-7c5c-43ef-8570-ad7cbce850a3'}"
83
+ ]
84
+ },
85
+ "execution_count": 12,
86
+ "metadata": {},
87
+ "output_type": "execute_result"
88
+ }
89
+ ],
90
+ "source": [
91
+ "from novita_client import NovitaClient\n",
92
+ "\n",
93
+ "\n",
94
+ "client = NovitaClient(api_key)\n",
95
+ "\n",
96
+ "res = client._post('/v3/async/instant-id', payload_data)\n",
97
+ "res"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": 14,
103
+ "metadata": {},
104
+ "outputs": [
105
+ {
106
+ "data": {
107
+ "text/plain": [
108
+ "V3TaskResponse(task=V3TaskResponseTask(task_id='fe2701c1-7c5c-43ef-8570-ad7cbce850a3', status=<V3TaskResponseStatus.TASK_STATUS_SUCCEED: 'TASK_STATUS_SUCCEED'>), images=[V3TaskImage(image_url='https://faas-output-image.s3.ap-southeast-1.amazonaws.com/prod/fe2701c1-7c5c-43ef-8570-ad7cbce850a3/2a889ab96bc946d5af40115ae47ccd46.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASVPYCN6LRCW3SOUV%2F20240227%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20240227T114145Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=7b71d07fc5cdc68eca8f0ef356a3139a2932dec78897ef0482ec36aac036042b', image_type='jpeg', image_url_ttl=3600)], videos=[])"
109
+ ]
110
+ },
111
+ "execution_count": 14,
112
+ "metadata": {},
113
+ "output_type": "execute_result"
114
+ }
115
+ ],
116
+ "source": [
117
+ "res2 = client.wait_for_task_v3(res['task_id'])\n",
118
+ "res2"
119
+ ]
120
+ }
121
+ ],
122
+ "metadata": {
123
+ "kernelspec": {
124
+ "display_name": "env",
125
+ "language": "python",
126
+ "name": "python3"
127
+ },
128
+ "language_info": {
129
+ "codemirror_mode": {
130
+ "name": "ipython",
131
+ "version": 3
132
+ },
133
+ "file_extension": ".py",
134
+ "mimetype": "text/x-python",
135
+ "name": "python",
136
+ "nbconvert_exporter": "python",
137
+ "pygments_lexer": "ipython3",
138
+ "version": "3.12.1"
139
+ }
140
+ },
141
+ "nbformat": 4,
142
+ "nbformat_minor": 2
143
+ }