Skip to content

Instantly share code, notes, and snippets.

View harshpyati's full-sized avatar
🎯
Focusing

Harsh Pyati harshpyati

🎯
Focusing
  • Bengaluru
View GitHub Profile
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@app.route('/captions', methods=['POST'])
@cross_origin(origin='localhost', headers=['Content- Type', 'Authorization'])
def get_differences():
global success
image_list = request.form["image_paths"].split(',')
model_path = '/Users/harshpyati/personal/fyp/text_gen/im2txt/im2txt/run_inference.py'
command = [
"python",
model_path,
"--input_files={}".format(image_list)
class PostsActivity : AppCompatActivity() {
private lateinit var postsViewModel: PostsViewModel
override fun onCreate(savedInstance : Bundle?){
// your code
postsViewModel = ViewModelProvider(this).get(PostsViewModel::class.java)
observeForChanges()
// your code
}
private fun observeForChanges() {
class PostsViewModel(application: Application) : AndroidViewModel(application) {
val apiClient = ApiClient()
val listOfPosts: LiveData<List<Posts>> = liveData {
val posts = apiClient.getPosts()
emit(posts)
}
}
private val apiInterface: ApiCalls
init {
val builder = Retrofit.Builder()
.baseUrl("https://jsonplaceholder.typicode.com")
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create()))
.build()
apiInterface = builder.create(ApiCalls::class.java)
}
suspend fun getPosts(): List<Posts> = apiInterface.getPosts()
import com.app.mvvmposts.model.data.Posts
import retrofit2.http.GET
interface ApiCalls {
@GET("/posts")
suspend fun getPosts(): List<Posts>
}
data class Posts(
val userId: Int,
val id : Int,
val title : String,
val body : String
)
override fun onCreate(savedInstanceState: Bundle?){
/* Your Existing Code */
vm = ViewModelProviders.of(this).get(ApiVM::class.java)
showTodo()
}
private fun showTodo(){
vm.apod.observe(this, Observer {
it?.let { apod ->
displayData(apod)
val repo: RetroRepo = RetroRepo()
val errorMessage = MutableLiveData<String>()
val apod: LiveData<Photos> = liveData {
try {
val retrievedTodo = repo.getAPOD()
emit(retrievedTodo)
} catch (httpException: HttpException) {
errorMessage.value = httpException.message()
} catch (socketTimeoutException: SocketTimeoutException) {
errorMessage.value = socketTimeoutException.message
suspend fun getAPOD(): Photos = webservice.getPhotos()